When generating a maven project in Eclipse, Eclipse uses the m2eclipse plugin to generate the project. If you use one of the quickstart archetypes (maven-archetype-quickstart), m2eclipse refers to the configuration of the maven-compiler-plugin, which uses the ridiculous default setting of Java 1.5.
If you don’t want to manually correct your project, by changing the pom.xml and update your project, every time you create a new project, you can also change the maven-compiler-plugin default setting:
- Go to you .m2 folder (in Windows C:\Users\\.m2)
- From the .m2 folder, go to repository\org\apache\maven\plugins\maven-compiler-plugin\3.1 (this folder will be available, if you created a new maven project from Eclipse at least once).
- Open maven-compiler-plugin-3.1.jar with a zip program.
- Goto META-INF/maven and open the plugin.xml
- The following lines are twice in the XML document:
<source implementation="java.lang.String" default-value="1.5">${maven.compiler.source}</source>
<target implementation="java.lang.String" default-value="1.5">${maven.compiler.target}</target>
- Change the default-value attribute to 1.8:
<source implementation="java.lang.String" default-value="1.8">${maven.compiler.source}</source>
<target implementation="java.lang.String" default-value="1.8">${maven.compiler.target}</target>
- Save the document and make sure that the plugin.xml is updated in the zip file.
From now on Eclipse creates Maven projects with Java version 1.8.