总结:
Spring 中的 AOP,有接口默认就用 JDK 动态代理,没有接口就用 CGLIB 动态代理。
但可以设置
@EnableAspectJAutoProxy(proxyTargetClass = true)
强制使用 CGLIB。Spring Boot 中的 AOP,
2.0
之前与 Spring 一样;2.0
之后默认使用 CGLIB 动态代理,如需使用 JDK 动态代理,需在application.properties
中配置spring.aop.proxy-target-class=false
。