spring的ioc容器生成的对象也是代理对象对吗

    一直以为spring的ioc容器生成的对象都是代理对象,其实这个是错误的。spring ioc默认的都是原生对象  只有通过aop增强的对象才是代理对象

有@Transactional  注解或者配置文件

<aop:config>
   <aop:pointcut id="txPointcut" expression="execution(* com..service.impl.*.*(..))" />
   <aop:advisor pointcut-ref="txPointcut" advice-ref="txAdvice" />
</aop:config>

有配置接口aop增强的类   得到的对象都是代理对象。

设置cglib动态代理针对于类的:

<aop:aspectj-autoproxy proxy-target-class="true"/>

注意:事物的传播机制也只有是代理对象操作的方法才起作用  

发布了55 篇原创文章 · 获赞 31 · 访问量 8万+

猜你喜欢

转载自blog.csdn.net/zengfanwei1990/article/details/79891906
今日推荐