How to gracefully modify the default JDK version of Maven

how to gracefully modify the default JDK version of Maven

May.11,2022

there are two ways to modify the default JDK version: global

for the project.
modify for the project (specify the jdk version in the project (modify the project's pom.xml file)
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.1</version>
<configuration>
<source>1.8</source>
<target>1.8</target>
</configuration>
</plugin>
</plugins>
</build>
Global modification (globally set jdk version (modify maven's settings.xml configuration file)
<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>

jenv is very interesting. Take a look at

.
Menu