maven显示1.5版本过期的解决办法


idea工具编译运行代码的时候总是提示这个问题,以下是简书@AnaKinSky的解释与解决方案

原因:

IDEA默认把项目的源代码版本设置为jdk1.5,目标代码设置为jdk1.8

解决方案:

1修改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>

2在项目的pom.xml文件中添加:


   
   
  1. <properties>
  2. <maven .compiler .source > 1.8 </maven .compiler .source >
  3. <maven .compiler .target > 1.8 </maven .compiler .target >
  4. </properties>

3打开项目配置,设置Modules的Language Level为”8”



最后按”Ctrl+Alt+S”打开设置,搜索”Java Compiler”,将默认jdk和当前modual的jdk版本切换为1.8即可

猜你喜欢

转载自blog.csdn.net/xyjworkgame/article/details/84886345