【问题标题】:IDEA was unable to find AspectJ compiler .jar among plugin dependenciesIDEA 无法在插件依赖项中找到 AspectJ 编译器 .jar
【发布时间】:2016-06-14 17:23:40
【问题描述】:

我正在尝试将 AspectJ 与 Intellij 一起使用。我在 intellij、Spring AOP/@AspectjSupport Aspectj 中启用了 Aspectj 插件,并且我在 Setting -> java compiler -> ajc 中设置了 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>

【问题讨论】:

  • 据我记得 IntelliJ 在 pom.xml 中找到 aspectjtools 时会检测 aspectJ。也许尝试版本 1.6.9?然后重新导入项目。我还认为对 aspectj-maven-plugin 的依赖是错误的。 Maven 插件不是以这种方式使用的依赖项 - 在插件部分中很好。
  • 我有同样的问题,但没有解决方案。有人找到解决此问题的方法吗?

标签: java maven intellij-idea aop aspectj


【解决方案1】:

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

顺便说一句:

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

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

【讨论】:

  • 投反对票的原因是什么?我给出了正确的答案。如果有问题,请发表评论,不要只是投反对票。此外,除了我之外,没有其他人愿意回答,而 OP 也不愿意提供任何反馈。有时我真的很想知道为什么我还在这样做......
  • 我有同样的问题,但还不确定解决方案。不管我做了什么更改,我都会遇到同样的错误。
  • @KayKay,你的评论太不具体了,我无法帮助你。如果我关于如何解决此问题的提示没有帮助,要么您根本没有使用它们,要么使用不正确,要么您的问题是另一个问题。请发布一个新问题,并附上完整的MCVE 和全面的问题描述。那我可以看看。
  • 我正在使用你提到的最新版本的aspectj,不知道如何在aspectj的插件管理部分添加配置。另外,这个问题只发生在 IntelliJ 中,似乎是 Intellij 中的配置问题。它工作正常,当我清除 .m2 存储库并再次重新导入时,它开始出现此错误。
猜你喜欢
  • 2015-08-23
  • 1970-01-01
  • 2015-01-07
  • 2022-01-03
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2012-04-28
  • 2019-11-02
相关资源
最近更新 更多