解决 IntelliJ IDEA中Warning:java: 源值1.5已过时, 将在未来所有发行版中删除

原因:

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

解决方案:

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”



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


猜你喜欢

转载自blog.csdn.net/liujian8654562/article/details/81207858