2015-12-14 11 views
4

我已经在Intellij(14.1.4 Ultimate)中打开了一个maven项目,并且JDK未被识别。intellij中有关Jdk5的错误,即使pom.xml明确将源设置为7

Error:(55, 50) java: diamond operator is not supported in -source 1.5 
    (use -source 7 or higher to enable diamond operator) 

这很奇怪,因为正常的设置是: - 当尝试运行出现以下错误的程序之一,在任何情况下,在IDE中查看时该文件有一堆在它的“红色” S在地方使用java7:

pom.xml

 <plugin> 
      <groupId>org.apache.maven.plugins</groupId> 
      <artifactId>maven-compiler-plugin</artifactId> 
      <configuration> 
       <source>1.7</source> 
       <target>1.7</target> 
      </configuration> 
     </plugin> 

在项目 - JDK级别设置为7:

enter image description here

同样,在模块:

enter image description here

但我们得到的问题,各种时试图编译(甚至重新导入Maven项目后):

enter image description here

注:本项目使用maven构建/在命令行上运行。

另请注意:我已经尝试吹掉Intellij项目并从头开始重建。行为没有变化。

更新以下是来自@Peter Lawrey的以下(接受)答案的结果。我们可以看到jdk神秘地设置为1.5。我已经手动更新到1.7。

enter image description here

回答

4

有时候的IntelliJ会很困惑,虽然我不知道为什么。您需要的设置是

File -> Settings -> Build, Execution, Deployment -> Compiler -> Java Compiler 

找到您的模块并将其更改为版本1.7而不是1.5。

我有许多模块和相同的父POM设置这个项目,有时只是其中一个模块会认为它1.5是其余的1.8。即跨许多模块的相同配置。

+0

有多少个不同的地方在IJ中寻找这个东西..;)是的,这是发生了什么:说1.5 – javadba

+0

@javadba我不明白这个屏幕的目的,为什么它不是模块/项目的一部分设置!? IntelliJ并不总是有AFAIK,它只会给我带来问题。 –

相关问题