maven下设置默认jdk版本和maven项目构建默认使用jdk版本
以下配置的内容为jdk1.8版本,如果需要其他版本,可以参照其配置的方式自行配置
在maven的config文件夹下的settings.xml配置文件中,找到profiles根标签,将以下代码加入其中
<profile>
<id>jdk-1.8</id>
<activation>
<activeByDefault>true</activeByDefault>
<jdk>1.8</jdk>
</activation>
<properties>
<maven.compiler.source>1.8</maven.compiler.source>
<maven.compiler.target>1.8</maven.compiler.target>
<maven.compiler.compilerVersion>1.8</maven.compiler.compilerVersion>
</properties>
</profile>
在maven项目中的pom.xml文件中,加入以下代码,然后更新maven依赖即可
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.6.0</version>
<configuration>
<source>1.8</source>
<target>1.8</target>
</configuration>
</plugin>
</plugins>
</build>

浙公网安备 33010602011771号