1、当Bean 有实现接口时,Spring 就会用JDK 的动态代理
2、当Bean 没有实现接口时,Spring 选择CGLib。
3、Spring 可以通过配置强制使用CGLib,只需在Spring 的配置文件中加入如下代码:
<aop:aspectj-autoproxy proxy-target-class="true"/>
参考资料:
https://docs.spring.io/spring/docs/current/spring-framework-reference/core.html