Solve the problem that the project JDK becomes 1.5 after Maven update project

1、 Problem description

Create a maven project in eclipse, and then change the JDK version to 1.7. As a result, the JDK version is restored to 1.5 every time Maven > update project is used.

2、 Cause analysis

Maven official documents are described as follows:

The compiler plug - in is used to compile the source files of the project Starting with version 3.0, the default compiler for compiling java source files is javax tools. Java compiler (if you are using java 1.6) If you want to force plug-ins to use javac, you must configure the plug-in option forcejavaccompileruse At the same time, it should be noted that the default settings of source option and target option are 1.5, which is independent of the JDK version when Maven is running If you want to change these default settings, you can refer to the description in setting the - source and - target of the java compiler to set the source and target options

This is a feature known to Maven. Unless you specify a version displayed in your POM file, the compiler default source / target version 1.5 will be used. The main reason is that Maven integration in eclipse plays a key role. It will generate project from POM files project,. Classpath and Settings, so unless the POM file specifies the correct JDK version, it will be reset to version 1.5 every time you update the project configuration.

3、 Solution

In POM Add the following configuration to the XML file:

As shown in the figure:

Re Maven > update project again to solve the problem.

The above is what Xiaobian brought to you to solve the problem that the project JDK becomes 1.5 after Maven update project. I hope you can support more programming tips~

The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
分享
二维码
< <上一篇
下一篇>>