Open your pom.xml
file and add the following lines on it:
<properties>
<maven.compiler.source>1.8</maven.compiler.source>
<maven.compiler.target>1.8</maven.compiler.target>
</properties>
Where 1.8
is the java version of your current JDK/JRE. Another way of doing this is adding a <build>
with the maven-compile-plugin
as
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.2</version> <!-- or whatever current version -->
<configuration>
<source>1.8</source>
<target>1.8</target>
</configuration>
</plugin>
</plugins>
</build>
EDIT
If you are looking for a way to make it work with Java versions 9+ please take a look at @JDelorean's answer down here and don't forget to give him an upvote as well :)
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…