Change Java Version in Maven project

In a Maven project, it’s confused that you may not stick on one Java version, even you set in Java Build Path. After a Maven update, or Maven build, it’s reset to the previous version.

There’s another option to set Java version in pom.xml file, by adding below lines:

<properties>
    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
    <maven.compiler.source>1.7</maven.compiler.source>
    <maven.compiler.target>1.7</maven.compiler.target>
</properties>

Now your project will keep on Java 7 now.