我刚刚完成了与AspectJ的网络项目的整合,并遇到了以下问题:
我有两个项目:api
(包含方面),web-app
,其中web-app
取决于api
。我正在使用Java 7并在api
项目中声明以下插件:
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>1.7</source>
<target>1.7</target>
<encoding>UTF-8</encoding>
</configuration>
</plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>aspectj-maven-plugin</artifactId>
<version>1.7</version>
<configuration>
<outxml>true</outxml>
<XterminateAfterCompilation>true</XterminateAfterCompilation>
</configuration>
<executions>
<execution>
<id>compile</id>
<goals>
<goal>compile</goal>
</goals>
</execution>
</executions>
</plugin>
网络应用程序项目包含以下内容:
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>aspectj-maven-plugin</artifactId>
<version>1.7</version>
<configuration>
<outxml>true</outxml>
<XterminateAfterCompilation>true</XterminateAfterCompilation>
<aspectLibraries>
<aspectLibrary>
<groupId>ua.com.winforce</groupId>
<artifactId>casino_aspect</artifactId>
</aspectLibrary>
</aspectLibraries>
</configuration>
<executions>
<execution>
<goals>
<goal>compile</goal>
</goals>
</execution>
</executions>
</plugin>
问题是当我在执行mvn instal
后尝试运行mvn clean
时,它失败并出现多个错误:
Syntax error, annotations are only available
if source level is 1.5 or greater
但第二个mvn install
效果很好。这是AspectJ插件的错误吗?
答案 0 :(得分:3)
尝试将源代码级别添加到aspectj maven plugin
:
<configuration>
<source>1.7</source>
<target>1.7</target>
<complianceLevel>1.7</complianceLevel>
</configuration>