原创转载请注明出处:http://agilestyle.iteye.com/blog/2326257
<aop:aspectj-autoproxy proxy-target-class="false"/> 基于接口,使用JDK动态代理
JDK Dynamic proxy can only proxy by interface (so your target class needs to implement an interface, which will also be implemented by the proxy class).
<aop:aspectj-autoproxy proxy-target-class="true"/> 基于类,需要使用cglib库
CGLIB (and javassist) can create a proxy by subclassing. In this scenario the proxy becomes a subclass of the target class. No need for interfaces.
Note:
这两种代理方式的使用使用了 策略模式 。
本文介绍了Spring AOP中两种不同的代理实现方式:基于接口的JDK动态代理与基于类的CGLIB代理,并探讨了这两种代理方式的具体应用场景及其实现原理。
3万+

被折叠的 条评论
为什么被折叠?



