有 Java 编程相关的问题?

你可以在下面搜索框中键入要查询的问题!

java使用Spring AOP proxyTargetClass=true进行嵌套方法调用

SpringAOP在通过接口公开的方法上运行良好。Spring AOP通过target class@enableSpectJautoproxy(proxyTargetClass=true)在代理上提供了一个选项

在本例中,目标类是代理,因此我假设它的所有方法-public、protected和private

   interface ISample {
      public method1();
   }

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

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

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

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


共 (1) 个答案