在IntelliJ IDEA 14.1中使用在Java项目中使用Maven时当没有在Maven中配置JDK编译版本、源码版本时,IDEA将默认的编译版本、源码版本设置为jdk5。
在IDEA中Language level 将使用默认的JDK5级别

目标版本也是默认为JDK5

当手动改为其他版本如:JDK8,但当你重新载入Maven项目时IDEA又将默认的Language level、Target bycode version设置为JDK5。
在项目中你将看到如下问题:
源值1.5已过时,将在未来所有版本中删除
目标值1.5已过时,将在未来所有版本中删除
这是因为IDEA默认把项目的源代码版本设置为jdk1.5,目标代码设置为jdk1.5


解决方案:
在项目的pom.xml文件中添加:
1 <properties> 2 <maven.compiler.source>1.8</maven.compiler.source> 3 <maven.compiler.target>1.8</maven.compiler.target> 4 </properties>
或者修改Maven的Settings.xml文件添加如下内容:
1 <profile> 2 <id>jdk-1.8</id> 3 <activation> 4 <activeByDefault>true</activeByDefault> 5 <jdk>1.8</jdk> 6 </activation> 7 <properties> 8 <maven.compiler.source>1.8</maven.compiler.source> 9 <maven.compiler.target>1.8</maven.compiler.target> 10 <maven.compiler.compilerVersion>1.8</maven.compiler.compilerVersion> 11 </properties> 12 </profile>
修改后IDEA将在源码jdk版本、目标jdk版本使用Maven中配置的jdk版本。


使用IntelliJ IDEA 13搭建Android集成开发环境图文教程 http://www.linuxidc.com/Linux/2015-09/123416.htm
IntelliJ IDEA 12 创建Web项目图文详细教程 http://www.linuxidc.com/Linux/2013-05/84213.htm
用IntelliJ IDEA开发Android程序图文教程 http://www.linuxidc.com/Linux/2013-03/81471.htm
IntelliJ IDEA 12开发haXe NME应用配置指南 http://www.linuxidc.com/Linux/2013-01/77227.htm
IntelliJ IDEA运行Play Framework的test mode http://www.linuxidc.com/Linux/2013-07/87694.htm
Ubuntu 13.04 安装IntelliJ IDEA 12 http://www.linuxidc.com/Linux/2013-11/93014.htm
IntelliJ IDEA 12创建Maven管理的Java Web项目(图解) http://www.linuxidc.com/Linux/2014-04/99687p2.htm
IntelliJ IDEA 常用快捷键列表及技巧大全 http://www.linuxidc.com/Linux/2015-04/116398.htm
IntelliJ IDEA 的详细介绍:请点这里
IntelliJ IDEA 的下载地址:请点这里
本文永久更新链接地址:http://www.linuxidc.com/Linux/2016-03/129507.htm
