The reason for the change of the JDK version of the Maven project:
1. The JDK version of a new Maven project does not correspond to the system version. 2. Right-click the Maven project -> Maven -> Update Project The JDK version has changed, 3. The operating system's JDK has been reinstalled with a new version, which is the cause of the first two phenomena main reason.
Modification method (if the system jdk version is 1.8):
Method 1: Specify the jdk version in the 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>
Method 2: Modify settings.xml, find the profiles node, and add in it
- <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>
Then the update project can be kept consistent with the system jdk version. It is recommended to use the second method to reduce the configuration of each project.