【问题标题】:Intellij ignoring Project java source levelIntellij 忽略项目 java 源级别
【发布时间】:2016-09-26 05:12:39
【问题描述】:
注意:这不是重复的。此版本的 spark 需要 jdk 1.7 或 1.8。父 pom.xml 条目如下所示:
<java.version>1.7</java.version>
如屏幕截图所示,我们有用于 SDK 和语言级别的 java 1.8:
这里是模块设置:
但 Intellij 对此感到困惑:
Error:(73, 51) java: diamond 运算符在 -source 1.5 中不受支持
(使用 -source 7 或更高版本来启用菱形运算符)
这是一个基于 OS/X 的 maven 构建的 spark 项目。 Intellij Ultimate 14.1.4
更新这是 jdk 的 pom.xml 条目
【问题讨论】:
标签:
intellij-idea
apache-spark
【解决方案1】:
如果您使用的是 Maven,请注意您的 pom.xml 文件。即使您的 IntelliJ 项目设置为 Java 8,您的项目也将使用 pom.xml 中设置的 Java 版本进行编译。
将此添加到您的 pom.xml 中
<properties>
<maven.compiler.source>1.8</maven.compiler.source>
<maven.compiler.target>1.8</maven.compiler.target>
</properties>
或者直接在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>