我正在使用maven和tycho插件来构建eclipse应用程序。我使用了一些java 8特性,如lambda表达式,但由于编译失败,它无法正确构建。
[ERROR] Failed to execute goal org.eclipse.tycho:tycho-compiler-plugin:1.0.0:compile (default-compile) on project ***.***: Compilation failure: Compilation failure:
[ERROR] .filter(Objects::nonNull)
[ERROR] ^^^^^^^^^^^^^^^^
[ERROR] Method references are allowed only at source level 1.8 or above
[ERROR] 2 problems (2 errors)
[ERROR] -> [Help 1]
[ERROR]
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR]
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoFailureException我的问题是:
发布于 2018-06-13 11:19:50
正如在.settings/org.eclipse.jdt.core.prefs中提到的,文件tycho-编译器-插件文档中的信息将传递给编译器。
因此,有必要按以下方式更新该文件:
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8
org.eclipse.jdt.core.compiler.compliance=1.8
org.eclipse.jdt.core.compiler.source=1.8发布于 2018-06-13 08:36:08
您必须在pom.xml文件中指定源级别:
<project>
<properties>
<maven.compiler.source>1.8</maven.compiler.source>
<maven.compiler.target>1.8</maven.compiler.target>
</properties>
</project>这与tycho无关,它是编译器插件。
您也可以配置插件本身。
请参考此页。
发布于 2021-09-27 09:34:34
我也遇到了同样的问题,解决方案是将JAVA_HOME设置为正确的JDK。
https://stackoverflow.com/questions/50832339
复制相似问题