IDEA无法在插件依赖项中找到AspectJ编译器.jar

sim*_*lue 7 java aop aspectj intellij-idea maven

我正在尝试将AspectJ与Intellij一起使用.我已经启用Aspectj在的IntelliJ插件,Spring AOP/@AspectjSupport 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.
Run Code Online (Sandbox Code Playgroud)

这是我的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>
Run Code Online (Sandbox Code Playgroud)

kri*_*aex 6

也许也使用插件版本是有意义的。我在你的 POM 中看不到任何内容。或者你在一个pluginManagement部分定义一个?只需修复您的 POM,IntelliJ IDEA 就可以工作。

顺便一提:

  • 您使用了一个非常旧的 AspectJ 版本。为什么?使用当前的,截至今天 1.8.8。
  • 您需要为 AspectJ 编译时编织声明的唯一依赖项是aspectjrt. 如果您希望 AspectJ Maven 插件升级其 AspectJ 版本,请在所需版本上定义插件依赖项aspectjtools,而不是模块依赖项。

如果您不完全理解此答案,请随时提出后续问题。

  • 投反对票的原因是什么?我给出了正确的答案。如果有什么不对的地方,请评论,不要直接投反对票。此外,除了我之外,没有人愿意回答,OP也不愿意提供任何反馈。有时候我真的很想知道为什么我还要这样做...... (3认同)