我正在尝试在maven项目中使用aspectj-maven-plugin
。在编译时,我得到:
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
然而,我在我的pom.xml中设置了以下内容:
<project.build.source>1.6</project.build.source>
<project.build.target>1.6</project.build.target>
我有一些依赖:
<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>
如何解决此问题?感谢。
解决方案
我在我的pom.xml中添加了以下内容,现在它可以正常工作:
<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>