运行Maven2 build时使用不同的Java源代码版本 [英] Using different Java source version when running Maven2 build
本文介绍了运行Maven2 build时使用不同的Java源代码版本的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在尝试使用通常的方式运行我的Maven构建:
I'm attempting to run my Maven build using the usual:
mvn clean install
我收到了一系列错误:
annotations are not supported in -source 1.3
(use -source 5 or higher to enable annotations)
如何在执行构建时使用-source 5。我的JAVA_HOME指向JDK 1.6。
How do I use -source 5 when performing the build. My JAVA_HOME is pointing to JDK 1.6.
推荐答案
将此添加到您的pom.xml:
Add this to your pom.xml:
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>2.3.2</version>
<configuration>
<source>1.6</source>
<target>1.6</target>
</configuration>
</plugin>
</plugins>
</build>
它也记录在 Maven FAQ 。
有关详细信息,请查看编译器插件文档。
For further information take a look at the Compiler Plugin documentation.
这篇关于运行Maven2 build时使用不同的Java源代码版本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文