每次重新加载pom时停止IntelliJ IDEA切换java语言级别(或更改默认项目语言级别) [英] stop IntelliJ IDEA to switch java language level every time the pom is reloaded (or change the default project language level)
问题描述
使用 IntelliJ 12,我有一个 java 项目,我使用带有 pom.xml 的 maven.我的项目使用的是java8,但导入项目时似乎默认项目语言级别已设置为6.
Using IntelliJ 12, I have a java project and I use maven with a pom.xml. My project is using java8, but it seems the default project language level has been set to 6 while importing the project.
我可以将语言级别更改为 8.0(F4 -> 模块 -> 语言级别)但是每次我编辑 pom.xml 时,项目级别都会切换回使用项目语言级别",我必须编辑它一次又一次的设置.
I can change the language level to 8.0 (F4 -> Modules -> Language level) however every time I edit my pom.xml the project level is switched back to "use project language level", and I have to edit this settings again and again.
是否需要在 pom.xml 中添加一些内容以将默认语言级别设置为 8.0?
Is there something I need to add to the pom.xml to set the default language level to 8.0?
推荐答案
根据 Mark 的评论,这里是如何做的:
As per Mark's comment, here is how to do it:
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.5.1</version>
<configuration>
<source>1.8</source>
<target>1.8</target>
</configuration>
</plugin>
</plugins>
</build>
这篇关于每次重新加载pom时停止IntelliJ IDEA切换java语言级别(或更改默认项目语言级别)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!