AspectJ与Spring& amp; IntelliJ无法正常工作

时间:2017-06-12 13:47:40

标签: java spring intellij-idea aspectj multi-module

我目前正在开发一个多模块gradle项目,其中所有模块都依赖于foo-common模块。 Foo-common是唯一没有主要功能的人。我想将AOP与AspectJ集成,为了做到这一点,我遵循了Official IntelliJ Documentation中的以下步骤:

  • 在安装了两个插件的情况下使用IntelliJ Idea Ultimate 2017.2
  • 已安装AspectJ
  • aspectjrt.jar创建了一个库,并使用this documentation将其作为依赖项添加到foo-common_mainfoo-bar_main模块。
  • 使用this documentation将IntelliJ中的编译器从javac更改为ajc
  • 已启用Build | AspectJ Weaving
  • 在启用了foo-common的{​​{1}}和foo-bar的项目结构中创建了AspectJ Facets

我的文件如下所示:

Aspect.java(Post-compile weave mode模块)

foo-common

ApplicationConfiguration.java(@Aspect public class TraceAspect extends Pointcuts { private static final Logger logger = LoggerFactory.getLogger(TraceAspect.class); @Before("call(* com.package.foo..*(..))") public void calling(JoinPoint joinPoint) { logger.trace("[CALL] " + joinPoint.getSignature().toString()); } @Before("execution(* com.package.foo..*(..))") public void initiating(JoinPoint joinPoint) { logger.trace("[EXEC] " + joinPoint.getSignature().toString()); } } 模块)

foo-bar

项目本身编译并运行。如果我尝试修改@SpringBootConfiguration public class ApplicationConfiguration{ private static final Logger logger = LogManager.getLogger(ApplicationConfiguration.class); @Bean public DummyClientFactory dummyClientFactory() { return new dummyClientFactoryImpl(); } } 以获得手动日志语句,那也可以。我可以看到IntelliJ使用智能来指出哪些建议连接到哪些方法。但是我无法通过Aspects看到生成的日志。

0 个答案:

没有答案