我在 Windows 10 上运行 Eclipse 2018-09 (4.9.0)。我使用的是 Open JDK 11 GA。我有一个指定为使用 Java 8 源代码的 Maven 项目。
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<maven.compiler.source>1.8</maven.compiler.source>
<maven.compiler.target>1.8</maven.compiler.target>
</properties>
在命令行上使用 Maven 3.5.3 编译得很好。使用 Eclipse Eclipse 2018-09 (4.9.0) 也可以很好地编译。
我将编译 Java 版本更改为 Java 11:
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<maven.compiler.source>11</maven.compiler.source>
<maven.compiler.target>11</maven.compiler.target>
</properties>
使用 Maven 3.5.3 在命令行上仍然可以很好地构建。但是在 Eclipse 2018-09 中,我到处都是错误:
'<>' operator is not allowed for source level below 1.7
Constructor references are allowed only at source level 1.8 or above
Default methods are allowed only at source level 1.8 or above
你明白了。
我已经习惯Alt+F5在 Eclipse 中更新我的 Maven 项目(和子项目)。我已经完成了彻底的清理和重建。
因为在命令行上使用 Maven 编译得很好,所以这一定是 Eclipse 问题,不是吗?当然,Eclipse 尚不支持所有新的 Java 11 功能,但此代码没有 Java 11 特定功能。怎么了?
慕标5832272
牛魔王的故事
相关分类