Please see the solution:
- Modify the settings.xml file of maven.
Add the following line and change the jdk version to the version you need:
<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>
-
Check whether the configuration file is referenced in eclipse. My user settting used the wrong location before.
Then update setttings.
3. Finally select the created project. After the project is updated, the referenced jdk version is automatically refreshed.