简体   繁体   English

Intellij忽略Project java源代码级别

[英]Intellij ignoring Project java source level

Note: this is not a duplicate. 注意:这不是重复的。 This version of spark requires either jdk 1.7 or 1.8. 此版本的spark需要jdk 1.7或1.8。 The parent pom.xml entry is shown here: 父pom.xml条目如下所示:

   <java.version>1.7</java.version>

As shown in the screenshot we have java 1.8 for the SDK and the language level: 如截图所示,我们有SDK 1.8的SDK和语言级别:

在此输入图像描述

And here are the modules settings: 以下是模块设置:

在此输入图像描述

But Intellij is just confused about that: 但Intellij对此感到困惑:

Error:(73, 51) java: diamond operator is not supported in -source 1.5 (use -source 7 or higher to enable diamond operator) 错误:(73,51)java:在-source 1.5中不支持菱形运算符(使用-source 7或更高版本来启用菱形运算符)

This is a spark project being built from maven on OS/X. 这是一个由OS / X上的maven构建的spark项目。 Intellij Ultimate 14.1.4 Intellij Ultimate 14.1.4

在此输入图像描述

Update Here is the pom.xml entry for the jdk 更新这里是jdk的pom.xml条目

If you are using Maven, please watch your pom.xml file. 如果您使用的是Maven,请查看您的pom.xml文件。 Even if your IntelliJ Project is set to Java 8 your project will compile with the version of Java set in your pom.xml. 即使您的IntelliJ项目设置为Java 8,您的项目也将使用您的pom.xml中设置的Java版本进行编译。

Add this to your pom.xml 将其添加到您的pom.xml中

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

Or directly in the maven plugin : 或者直接在maven插件中:

<plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-compiler-plugin</artifactId>
            <version>2.2</version>
            <configuration>
                <source>1.8</source> <!-- java version here -->
                <target>1.8</target> <!-- java version here -->
            </configuration>
 </plugin>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM