2016-03-02 2433 views
5

我正在使用AspectJ與Intellij一起使用。我已經在intellij,Spring AOP/@AspectjSupport Aspectj中啓用了Aspectj插件,並且我已經在Setting -> java compiler -> ajc中設置了ajc編譯器。IDEA無法在插件依賴關係中找到AspectJ編譯器.jar

我收到此錯誤消息。

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> 
+0

據我所知,當IntelliJ在pom中發現 aspectjtools時,它將檢測到aspectJ。也許嘗試版本1.6.9?然後重新導入該項目。我也會爭辯說,對 aspectj-maven-plugin的依賴是錯誤的。 Maven插件沒有這種方式的依賴性 - 它在插件部分很好。 – wemu

回答

1

也許是有意義的還使用了插件版本。我在你的POM裏看不到任何東西。或者你是否在pluginManagement部分定義了一個?只需修復您的POM,IntelliJ IDEA即可運行。

順便說一句:

  • 你使用一個非常老的AspectJ版本。爲什麼?使用目前的1.8.8。
  • 您需要爲AspectJ編譯時織入聲明的唯一依賴項爲aspectjrt。如果您希望AspectJ Maven插件升級其AspectJ版本,請在所需版本的aspectjtools上定義插件依賴項,而不是模塊依賴項。

如果您不完全理解此答案,隨時可以提出後續問題。