Niu Ma's daily regain of SpringMVC's "invalid target distribution"
Question: screenshot of death
Problem solving idea: This is an error caused by a mismatch of JDK versions.
Let me first talk about the key to the problem, and then elaborate on the solution steps:
Friends who encounter this problem are most likely to encounter it when writing Spring projects, which requires Maven to manage the project, and whether the jdk version of Maven matches is the root cause of this problem.
The root of this problem is whether the JDK used by your existing project is the same as the JDK version when maven is built.
Organized a solution:
- The first thing programmers think of is the operation of modifying the jdk version in Setting.
It is true that the jdk selection of the project can be changed in the Setting.
Generally, the problem cannot be solved after this operation.
- Modify the project configuration in Structure
Both Source and Dependencies need to be modified to the jdk version required by the project
Again, this operation still does not solve the problem. Still getting the same error when running the project??.
- Here you need the last step of operation, go to Setting to find the path of Maven's set.xml file
Delete the original JDK configuration (version 17), add the target jdk version, and provide version 1.8 configuration information here.
<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>
In the end, it's the K of O.