只要在pom.xml中指定Java版本即可。
方法一
在pom.xml文件中添加:
<properties>
<!--指定Java版本-->
<maven.compiler.source>1.8</maven.compiler.source>
<maven.compiler.target>1.8</maven.compiler.target>
</properties>
方法二
在pom.xml文件中添加:
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.8.1</version>
<configuration>
<!--指定Java版本-->
<source>1.8</source>
<target>1.8</target>
</configuration>
</plugin>
</plugins>
</build>