使用Apache Maven的mvn clean包构建.war时出现以下错误。有人可以给我一个解决方法吗?感谢。
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 8.593s
[INFO] Finished at: Thu Sep 05 22:35:10 GMT+05:30 2013
[INFO] Final Memory: 13M/24M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.codehaus.mojo:aspectj-maven-plugin:1.0:compile (default) on project application: Compiler errors :
[ERROR] error at import javax.annotation.PreDestroy;
[ERROR] ^^^^^^^^^^^^^^^
[ERROR] C:\Documents and Settings\User\My Documents\application\application\src\main\java\com\Service\MyService.java:13:0::0 The import javax.annotation cannot be resolved
[ERROR] -> [Help 1]
[ERROR]
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR]
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoExecutionException
答案 0 :(得分:1)
你的pom.xml是否设置了Java编译器版本?
maven-compiler的一些(所有?)版本采用Java 1.4编译器......这当然会引起问题,因为Annotations在Java 1.5中是新的。
您可以通过在项目的pom.xml中包含maven-compiler-version
的插件块来强制它到Java 7并设置其源和目标属性......如下所示:
<project>
[...]
<build>
[...]
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.1</version>
<configuration>
<source>1.7</source>
<target>1.7</target>
</configuration>
</plugin>
</plugins>
[...]
</build>
[...]
</project>
答案 1 :(得分:0)
从here下载JSR305以解决问题。