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.
Check this page and I see a "complianceLevel" configuration property in that example; setting that to 1.5 or 1.6 might do the trick (since they have a minimum of 1.4, I'm guessing that's the default).
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.