用maven创建java工程时,默认的编译版本是jdk1.5。可以在setting.xml中改变默认的编辑版本,在Setting.xml文件中的激活profile中添加以下属性:
<properties>
<maven.compiler.source>1.6</maven.compiler.source>
<maven.compiler.target>1.6</maven.compiler.target>
<maven.compiler.compilerVersion>1.6</maven.compiler.compilerVersion>
</properties>
也可以在项目的pom文件中,加入以下配置:
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
扫描二维码关注公众号,回复:
642848 查看本文章
<version>2.0.2</version>
<configuration>
<source>1.6</source>
<target>1.6</target>
<encoding>${project.build.sourceEncoding}</encoding>
</configuration>
</plugin>