[英]Cannot change Java source level to 1.7 in Eclipse with Maven
I tried using a multi-catch statement in my Java Project.我尝试在我的 Java 项目中使用多捕获语句。 It doesn't give any errors in the IDE, but when I do Run As->Maven Install
I get the following error (removed personal file paths as those are not relevant I think):它在 IDE 中没有给出任何错误,但是当我执行Run As->Maven Install
时,出现以下错误(删除了个人文件路径,因为我认为这些路径不相关):
Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.1:compile (default-compile) on project: Compilation failure
MyClass.java:[137,39] multi-catch statement is not supported in -source 1.5
[ERROR] (use -source 7 or higher to enable multi-catch statement)
As per the other answers on this site, I tried changing the Java version in my project properties.根据本网站上的其他答案,我尝试在我的项目属性中更改 Java 版本。 However, everything was already set to Java 1.7.但是,所有内容都已设置为 Java 1.7。 My Java Build Path我的Java 构建路径
My Java Compiler settings:我的Java 编译器设置:
What should I change to be able to use Java 1.7 properly?我应该改变什么才能正确使用 Java 1.7?
Okay somehow I missed this post before.好吧,我以前错过了这篇文章。 I didn't come up at all when googling about the exact error strangely enough.奇怪的是,当我在谷歌上搜索确切的错误时,我根本没有出现。 To fix it I simply had to add:要修复它,我只需添加:
<properties>
<maven.compiler.source>1.7</maven.compiler.source>
<maven.compiler.target>1.7</maven.compiler.target>
</properties>
to my project's pom.xml as maven was not using the java version from my eclipse project settings.到我项目的 pom.xml 因为 maven 没有使用我的 Z6B18A677C 项目设置中的 java 版本。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.