Maven "build path specifies execution environment J2SE-1.5", even though I changed it to 1.7
All of the answers above may work for the time being but whenever you run maven on the command line or Maven → Update project… the JDK will be reset, this was also the question as I understand it.
To fix this for good add the following code to your pom file. Remember to do a Maven → Update project… afterwards or mvn clean compile
at the command line.
<build>
<pluginManagement>
<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>
</pluginManagement>
</build>
- Right-click on your project
- Click Properties
- Click the "Java Compiler" option on the left menu
- Under JDK compliance section on the right, change it to "1.7"
- Run a Maven clean and then Maven build.
I know this is an old topic. I had the same problem. I tested all the answers about this topic. And nothing worked here... but i found another solution.
Go to pom->overview and add these to you properties:
- Name: "maven.compiler.target" Value: "1.7"
and
- Name: "maven.compiler.source" Value: "1.7"
Now do a maven update.