I am trying to use the aspectj-maven-plugin
in a maven project. At compile time, I get:
Syntax error, annotations are only available if source level is 5.0
Syntax error, annotations are only available if source level is 5.0
Syntax error, annotations are only available if source level is 5.0
Yet, I set the following in my pom.xml:
<project.build.source>1.6</project.build.source>
<project.build.target>1.6</project.build.target>
I have some dependencies to:
<dependency>
<groupId>org.aspectj</groupId>
<artifactId>aspectjrt</artifactId>
<version>1.6.11</version>
</dependency>
<dependency>
<groupId>org.codehaus.mojo</groupId>
<artifactId>aspectj-maven-plugin</artifactId>
<version>1.4</version>
</dependency>
How do I solve this issue? Thanks.
Solution
I added the following in my pom.xml and now it works:
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>aspectj-maven-plugin</artifactId>
<version>1.4</version>
<executions>
<execution>
<goals>
<goal>compile</goal>
<goal>test-compile</goal>
</goals>
<configuration>
<source>${project.build.source}</source> <- Addition
<target>${project.build.target}</target> <- Addition
</configuration>
</execution>
</executions>
</plugin>
You can explicity set the source parameter of the aspectj plugin. Docs here.
I was able to solve this issue by adding the following to my pom:
<properties>
<project.build.java.target>1.6</project.build.java.target>
</properties>
was able to find this from this post.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With