question:
1. When creating the maven project, the jdk version is version 1.5, and the one you installed is version 1.7 or 1.8.
2. Every time you right-click the project name -maven->update project, the project jdk version changes, and returns to version 1.5 or other versions
Solution:
Solution 1: Specify the jdk version in the pom.xml in the project, as follows:
<build> <plugins> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-compiler-plugin</artifactId> <version>3.1</version> <configuration> <source>1.7</source> <target>1.7</target> </configuration> </plugin> </plugins> </build>
This method can only ensure that the project is jdk1.7 version. Every time a new project is created, the face code must be added. It is not recommended to use it. The second method is recommended.
Solution 2: Find the settings.xml file in the maven installation directory and add the following code to it
<profile> <id>jdk-1.7</id> <activation> <activeByDefault>true</activeByDefault> <jdk>1.7</jdk> </activation> <properties> <maven.compiler.source>1.7</maven.compiler.source> <maven.compiler.target>1.7</maven.compiler.target> <maven.compiler.target>1.7</maven.compiler.target> <maven.compiler.compilerVersion>1.7</maven.compiler.compilerVersion> </properties></profile>
After adding, set eclipse. window->preferences->maven->user settings, user settings where select settings.xml file in the maven installation directory. The following figure
After the setup is completed, right-click the project ->maven->update project, so that every time you create a new maven project, the default is jdk1.8 version.
Solution three:
In solution 2, the default settigs.xml file path of user settings is: c:/users/Hxinguan/.m2/settings.xml, as shown in the figure below. Just copy the settings.xml file to this directory and update project.
Summarize
The above is the method of modifying the default jdk version of maven to 1.7 by the editor. I hope it will be helpful to everyone. If you have any questions, please leave me a message and the editor will reply to everyone in time. Thank you very much for your support to Wulin.com website!