当我没有在我的 pom.xml 文件中定义如下内容时,在我的系统上的哪个位置为 Maven 定义了在编译时使用哪个版本的 Java JDK(我的系统上安装了几个版本,JAVA_HOME
指向其中之一)?
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>2.3.2</version>
<configuration>
<source>1.5</source>
<target>1.5</target>
</configuration>
</plugin>
</plugins>
</build>
最佳答案
Maven 文档说
The Compiler Plugin is used to compile the sources of your project. The default compiler is javac and is used to compile Java sources. Also note that at present the default source setting is 1.5 and the default target setting is 1.5, independently of the JDK you run Maven with. If you want to change these defaults, you should set source and target as described in Setting the
-source
and-target
of the Java Compiler.
引用:http://maven.apache.org/plugins/maven-compiler-plugin/index.html
Maven 的 Jira 上有这个有趣的线程 Change default source level to 1.5
编辑:
Maven 3.0 及更高版本的更新:
The Compiler Plugin is used to compile the sources of your project. Since 3.0, the default compiler is javax.tools.JavaCompiler (if you are using java 1.6) and is used to compile Java sources. If you want to force the plugin using javac, you must configure the plugin option forceJavacCompilerUse.
来源:http://maven.apache.org/plugins/maven-compiler-plugin/index.html
谢谢 nachteil感谢指出。
关于maven - Maven编译器使用的JDK版本在哪里指定?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9603591/