我正在尝试将 AspectJ 与 Intellij 结合使用。我在 intellij、Spring AOP/@Aspectj
和 Support Aspectj
中启用了 Aspectj
插件,并且设置了 ajc
编译器在 Setting -> java compiler -> ajc
中。
我收到此错误消息。
AspectJ Support
IDEA was unable to find AspectJ compiler .jar among plugin dependencies.
Please fix <aspectj-maven-plugin> in '/home/manoj/stuff/moghul/Git_backend/dropwizard/pom.xml' and re-import a project,or set compiler manually via Settings | Compiler | Java Compiler.
这是我的 pom.xml
<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>3.8.1</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>io.dropwizard.metrics</groupId>
<artifactId>metrics-core</artifactId>
<version>3.1.0</version>
</dependency>
<dependency>
<groupId>io.dropwizard.metrics</groupId>
<artifactId>metrics-graphite</artifactId>
<version>3.1.2</version>
</dependency>
<dependency>
<groupId>io.dropwizard.metrics</groupId>
<artifactId>metrics-annotation</artifactId>
<version>3.1.2</version>
</dependency>
<dependency>
<groupId>io.astefanutti.metrics.aspectj</groupId>
<artifactId>metrics-aspectj</artifactId>
<version>1.1.0</version>
</dependency>
<dependency>
<groupId>org.aspectj</groupId>
<artifactId>aspectjrt</artifactId>
<version>1.6.9</version>
</dependency>
<dependency>
<groupId>org.aspectj</groupId>
<artifactId>aspectjtools</artifactId>
<version>1.6.2</version>
</dependency>
<dependency>
<groupId>org.aspectj</groupId>
<artifactId>aspectjweaver</artifactId>
<version>1.8.8</version>
</dependency>
<dependency>
<groupId>org.codehaus.mojo</groupId>
<artifactId>aspectj-maven-plugin</artifactId>
<version>1.8</version>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>aspectj-maven-plugin</artifactId>
<configuration>
<aspectLibraries>
<aspectLibrary>
<groupId>io.astefanutti.metrics.aspectj</groupId>
<artifactId>metrics-aspectj</artifactId>
</aspectLibrary>
</aspectLibraries>
</configuration>
<executions>
<execution>
<goals>
<goal>compile</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
最佳答案
也许也可以使用插件版本。我在你的 POM 中看不到任何内容。或者您是否在 pluginManagement
部分中定义了一个?只需修复您的 POM,IntelliJ IDEA 即可正常工作。
顺便说一句:
- 您使用的是非常旧的 AspectJ 版本。为什么?使用当前版本,即今天的 1.8.8。
- 您需要为 AspectJ 编译时编织声明的唯一依赖项是
aspectjrt
。如果您希望 AspectJ Maven 插件升级其 AspectJ 版本,请定义对aspectjtools
所需版本的插件依赖性,而不是模块依赖性。
如果您不完全理解此答案,请随时提出后续问题。
关于java - IDEA 无法在插件依赖项中找到 AspectJ 编译器 .jar,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35737375/