在maven-update project后又会变成默认的1.5版本,甚为烦恼。如题:maven构建的项目中默认的java版本是1.5,并且我们在项目属性里面更改了之后,
下面提供解决方法:
1:在maven的setting.xml文件中设置
<profile>
<id>jdk1.8</id>
<activation>
<activeByDefault>true</activeByDefault>
<jdk>1.8</jdk>
</activation>
<properties>
<maven.compiler.source>1.8</maven.compiler.source>
<maven.compiler.target>1.8</maven.compiler.target>
<maven.compiler.compilerVersion>1.8</maven.compiler.compilerVersion>
</properties>
</profile>
2:在项目的pom.xml文件中设置
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.3</version>
<configuration>
<source>1.7</source>
<target>1.7</target>
</configuration>
</plugin>
推荐第一种,因为在maven的setting文件中设置只需要设置一次,而在项目中设置,就需要没创建一个项目都要设置一次。