事实证明,有一个org.aspectj.lang.Aspects
专门为此目的提供的类。看来该aspectOf()
方法是由LTW添加的,这就是为什么它在XML配置中可以正常工作,而不是在编译时起作用的原因。
为了解决此限制,org.aspectj.lang.Aspects
提供了一种aspectOf()
方法:
@Bean
public com.xyz.profiler.Profiler profiler() {
com.xyz.profiler.Profiler profiler = Aspects.aspectOf(com.xyz.profiler.Profiler.class);
profiler.setProfilingStrategy(jamonProfilingStrategy()); // assuming you have a corresponding @Bean method for that bean
return profiler;
}