Spring aspectj 影响

Spring aspectj implications

我正在从事一个项目,该项目有一个方面并且在配置上有 @EnableAspectJ

这意味着spring的所有代理都是使用aspectj创建的?那么 @Transactional@Async 会发生什么?它应该将模式属性设置为使用 aspectJ 吗?或者它会使用 CGLIB 和 Aspectj?

docs 开始,您需要设置 proxyTargetClass=true 以使用 CGLIB 代理,否则将使用标准 JDK 基于接口的代理。

Users can control the type of proxy that gets created for FooService using the proxyTargetClass() attribute. The following enables CGLIB-style 'subclass' proxies as opposed to the default interface-based JDK proxy approach.

 @Configuration
 @EnableAspectJAutoProxy(proxyTargetClass=true)
 public class AppConfig {
   // ...
 }