Java 对于低于 1.7 的源级别,此处不允许使用资源规范
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/20806470/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Resource specification not allowed here for source level below 1.7
提问by big
While running java program getting following error in eclipse
在eclipse中运行java程序时出现以下错误
Caused by: java.lang.Error: Unresolved compilation problem:
Resource specification not allowed here for source level below 1.7
Although I am using java 1.7.25 and all eclipse settings are in place but not sure why getting this error
虽然我使用的是 java 1.7.25 并且所有 eclipse 设置都已到位,但不确定为什么会出现此错误
SOLUTION.
解决方案。
Problem solved by updating project in eclipse using maven.
通过使用 Maven 在 Eclipse 中更新项目解决了问题。
采纳答案by Ivan Mushketyk
Despite of the fact that you are using Java 1.7 you can compile source code as if you had compiler from Java 1.6 (this can be useful for example for cross-compilation). As Shivam Tiwarisaid in Eclipse you can change it in window->preferences->java->Compiler Compiler
尽管您使用的是 Java 1.7,但您可以像使用 Java 1.6 的编译器一样编译源代码(例如,这对于交叉编译很有用)。正如Shivam Tiwari在 Eclipse 中所说,您可以在 window->preferences->java->Compiler Compiler 中更改它
If you are using Maven you should add the following plugin:
如果您使用 Maven,则应添加以下插件:
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>2.5.1</version>
<configuration>
<source>1.7</source>
<target>1.7</target>
</configuration>
</plugin>
回答by Jay Teli
Maven update with 'Force snapshot release' did the trick. pom.xml doesn't need to be changed.
带有“强制快照发布”的 Maven 更新成功了。pom.xml 不需要更改。