IntelliJ IDEA 源值1.5已过时,将在未来所有版本中删除{{1021}}

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

原因:

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

解决方案:

1修改Maven的Settings.xml文件添加如下内容

<profile>
  <id>jdk-1.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文件中添加:

<properties>
 <maven.compiler.source>1.8</maven.compiler.source>
  <maven.compiler.target>1.8</maven.compiler.target>
</properties>

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


222222.png


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

猜你喜欢

转载自blog.csdn.net/zzhuan_1/article/details/80440200