IDEA中maven项目的language level 修改后自动重置问题

问题:
我的JDK使用的是1.8,但是在IDEA中编写1.8特性的代码时却会爆红,而且编译也通不过,确定不是代码的问题后。转而发现了Language Level这个东西,IDEA中默认Language Level 5(即对应JDK1.5),打开Module Settings将Language level修改为8(即对应JDK1.8),但是重新刷新maven依赖时,又会变成Language Level 5。

解决方法:

通过指定maven项目的Language Level值,来防止每次自动重置Language Level。在maven项目的pom.xml 中添加如下内容即可:

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

<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.6.0</version>
<configuration>
<source>1.8</source>
<target>1.8</target>
</configuration>
</plugin>
</plugins>
</build>

posted @   江南小镇的一缕阳光  阅读(761)  评论(0编辑  收藏  举报
相关博文:
阅读排行:
· TypeScript + Deepseek 打造卜卦网站:技术与玄学的结合
· 阿里巴巴 QwQ-32B真的超越了 DeepSeek R-1吗?
· 【译】Visual Studio 中新的强大生产力特性
· 10年+ .NET Coder 心语 ── 封装的思维:从隐藏、稳定开始理解其本质意义
· 【设计模式】告别冗长if-else语句:使用策略模式优化代码结构
点击右上角即可分享
微信分享提示