您好, 欢迎来到 !    登录 | 注册 | | 设为首页 | 收藏本站

使用Spring IoC和JavaConfig配置AspectJ方面?

使用Spring IoC和JavaConfig配置AspectJ方面?

事实证明,有一个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;
}
java 2022/1/1 18:17:33 有467人围观

撰写回答


你尚未登录,登录后可以

和开发者交流问题的细节

关注并接收问题和回答的更新提醒

参与内容的编辑和改进,让解决方法与时俱进

请先登录

推荐问题


联系我
置顶