Maven 没有使用正确的 Java 编译器 [英] Maven is not using the proper Java compiler
问题描述
我在 Solaris 10 上使用 Maven 2.2.在编译我的 JAR 项目时,我想在其中使用 Java 6 编译器,我遇到编译错误,例如……
I'm using Maven 2.2 on Solaris 10. When compiling my JAR project, in which I want to use a Java 6 compiler, I get compilation errors like …
[INFO] Compilation failure
/home/davea/selenium/src/main/java/com/cm/systems/selenium/util/TestSuite.java:[17,18] generics are not supported in -source 1.3
(使用 -source 5 或更高版本来启用泛型)私有向量文件集 = new Vector();
(use -source 5 or higher to enable generics) private Vector filesets = new Vector();
我已将 $JAVA_HOME 更改为指向我的 Java 6 安装(系统上还有另一个 Java 5 安装)……
I have changed my $JAVA_HOME to point to my Java 6 installation (there is another Java 5 installation on the system) …
-bash-3.00$ java -version
java version "1.6.0_25"
Java(TM) SE Runtime Environment (build 1.6.0_25-b06)
Java HotSpot(TM) Server VM (build 20.0-b11, mixed mode)
-bash-3.00$ echo $JAVA_HOME
/home/davea/jdk1.6.0_25
但错误仍然存在.我还需要做什么?谢谢,-戴夫
Yet still the errors persist. What else do I need to do? Thanks, - Dave
推荐答案
默认情况下,编译器插件使用 source=1.3 和 target=1.3.您必须手动将其设置为 1.6:
By default, the compiler plugin uses source=1.3 and target=1.3. You have to manually set it to 1.6:
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<version>2.3.1</version>
<configuration>
<source>1.6</source>
<target>1.6</target>
</configuration>
</plugin>
这篇关于Maven 没有使用正确的 Java 编译器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!