Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

IDEA was unable to find AspectJ compiler .jar among plugin dependencies

I'm using trying to use AspectJ with Intellij. I have enabled Aspectj plugins in intellij, Spring AOP/@Aspectj and Support Aspectj and I have set the ajc compiler in Setting -> java compiler -> ajc.

I get this error message.

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.

Here is my 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>
like image 810
simplyblue Avatar asked Mar 02 '16 02:03

simplyblue


1 Answers

Maybe it makes sense to also use a plugin version. I cannot see any in your POM. Or do you define one in a pluginManagement section? Just fix your POM and IntelliJ IDEA will work.

By the way:

  • You use a very old AspectJ version. Why? Use the current one, as of today 1.8.8.
  • The only dependency you need to declare for AspectJ compile-time weaving is aspectjrt. If you want AspectJ Maven plugin to upgrade its AspectJ version, define a plugin dependency on the desired version of aspectjtools, not a module dependency.

Feel free to ask follow-up questions if you do not fully understand this answer.

like image 144
kriegaex Avatar answered Oct 27 '22 18:10

kriegaex