的IntelliJ IDEA给java7错误虽然java8

问题描述:

编译我有一个Maven项目并已配置的IntelliJ用java 8.我的一位同事推它采用默认关键字在界面的变化。自从我同步他的更改以来,每次编译都失败了。的IntelliJ IDEA给java7错误虽然java8

我目前难住,无法在网上找到答案。

以下是来自Intellij的错误消息。目前在我的设备上安装了1.8.0_111-b14版本的Java和Intellij 2016.3.4

Information:18/10/17, 1:06 PM - Compilation completed with 1 error and 0 warnings in 3s 442ms 
Information:javac 1.8.0_111 was used to compile java sources 
Error:(17, 16) java: default methods are not supported in -source 1.7 (use -source 8 or higher to enable default methods) 
+1

你哈瓦在你的pom.xml一个maven编译器插件? –

明白了。我必须更改Maven插件的POM文件和版本。

 <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> 

项目结构>项目>项目SDK。设为1.8。

如果没有帮助,项目结构>模块,并确保您的模块设置为语言级别8

+0

此外,我将在设置 - >构建,Excetution,部署 - >编译器 - > Java编译器下设置目标字节码版本为1.8 –

以下内容添加到您的pom.xml:

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

这将配置maven传递给JDK进行编译的JDK目标版本

将您的java版本设置为java8并执行更新。此外,执行invalidate cache/restart