版权声明:wuyujin1997 https://blog.csdn.net/wuyujin1997/article/details/83120164
默认版本
maven项目中,编译器和JRE的版本默认为1.5(所以Alt + F5刷新项目后,多个参数值会变成1.5)
参数如下(选中项目,Alt + Enter,查看项目属性):
Java Build Path下的Libraries下的JRE System Lirbrary的版本。
Java Compiler下的JDK Compiler的版本。
Maven下的Project Facts下的Java的版本。
如何永久设置maven项目的JDK版本?配置pom.xml。
配置pom.xml(两种方法皆可)
配置properties节点及其子节点
配置build>plugins>plugin节点及其子节点
配置properties节点下的maven编译器信息。
<properties>
<maven.compiler.source>1.8</maven.compiler.source>
<maven.compiler.target>1.8</maven.compiler.target>
</properties>
配置build>plugins>plugins>configuration节点下的source和target节点值。
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.8.0</version>
<configuration>
<source>1.8</source>
<target>1.8</target>
</configuration>
</plugin>
</plugins>
javac命令的参数
-source <发行版> 提供与指定发行版的源兼容性
-target <发行版> 生成特定 VM 版本的类文件