java 语法错误,注释仅在源级别为 5.0 时可用 - Maven 中的 AspectJ
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/7361231/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Syntax error, annotations are only available if source level is 5.0 - AspectJ in Maven
提问by Jér?me Verstrynge
I am trying to use the aspectj-maven-plugin
in a maven project. At compile time, I get:
我正在尝试aspectj-maven-plugin
在 Maven 项目中使用 。在编译时,我得到:
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:
然而,我在 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:
我在我的 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>