There is a problem today:
When you create a new Web project with Maven in Eclipse and then update it with MAVEN, the JDK version automatically becomes 1.5.
By finding the data, we finally found the following explanation in the documentation for the MAVEN compiler plugin (maven Compiler Plugin):
The Compiler Plugin is used to compile the sources of your project. Since 3.0, the default compiler is Javax.tools.JavaCompiler (if you were using Java 1.6) and is used to compile Java source S. If you want to force the plugin using javac, you must configure the plugin option Forcejavaccompileruse.
Also note that at PR esent The default source setting is 1.5 and the default target setting is 1.5, Ind Ependently of the JDK you run Maven with. If you want to change these defaults, you should set source and target as described in Setting the-sour Ce And-target of the Java Compiler.
There are two ways to set the compiler version. Here is the code snippet for the Pom.xml file:
The first method:
<Project> <Properties> <Maven.compiler.source>1.8</Maven.compiler.source> <Maven.compiler.target>1.8</Maven.compiler.target> </Properties></Project>
The second method:
<Project> <Build> <Plugins> <plugin> <groupId>Org.apache.maven.plugins</groupId> <Artifactid>Maven-compiler-plugin</Artifactid> <version>3.7.0</version> <Configuration> <Source>1.8</Source> <Target>1.8</Target> </Configuration> </plugin> </Plugins> </Build></Project>
Finally, right-click on the project in Eclipse and re-update the project with MAVEN.
How to set the Java compiler version in the Maven Pom.xml file