proxy-target-class="false"与proxy-target-class="true"区别

原创转载请注明出处:https://www.cnblogs.com/agilestyle/p/11484063.html

 

<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:

这两种代理方式的使用使用了 策略模式 。

 

posted @ 2019-09-08 00:25  李白与酒  阅读(904)  评论(0编辑  收藏  举报