问题描述
使用IntelliJ 12,我有一个java项目,我使用maven和pom.xml。
我的项目使用的是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语言级别(或更改默认项目语言级别)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!