嵌套方法调用 Spring AOP proxyTargetClass=true

Does nested method calls with Spring AOP proxyTargetClass=true

Spring AOP 适用于通过接口公开的方法。 Spring AOP 通过目标提供代理选项 class @EnableAspectJAutoProxy(proxyTargetClass=true)

在这种情况下,目标 class 是代理,因此我假定它的所有方法 - public、受保护和私有。

   interface ISample {
      public method1();
   }

class Sample implements ISample { 
   @LogMe
   public method1() {
     ...
     method2();
   }

   @LogMe
   private method2() {
     ...
   }
}

我在 class 路径中配置了 cglib 库,配置 class 有 @EnableAspectJAutoProxy(proxyTargetClass=true) 方面 class 有@Aspect 和@Component。方面 class 如果用 @LogMe 注释,则记录所有方法调用。

问题是这个设置 method2() 调用没有被记录?如果代理在目标 class 上,这应该行不通吗?

CGLIB 代理不适用于我的情况。但是我用的是AspectJ loadtime weaving.

线程中有更多详细信息