spring Eclipse JAX-RS(REST Web 服务)2.0 需要 Java 1.6 或更新版本
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/30082476/
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
Eclipse JAX-RS (REST Web Services) 2.0 requires Java 1.6 or newer
提问by BrokenFrog
i'm new to web service and i'm trying to do a project using jax-rs rest and spring in eclipse. I use java 1.8 but eclipse shows me an error that jax-rs 2.0 requires java 1.6 or newer error and my project won't work
我是 Web 服务的新手,我正在尝试在 Eclipse 中使用 jax-rs rest 和 spring 来做一个项目。我使用 java 1.8,但 eclipse 向我显示了一个错误,即 jax-rs 2.0 需要 java 1.6 或更新的错误,我的项目将无法工作
This is the project explorer and error's screenshot. I tried to google it but can't get any english solutions
这是项目资源管理器和错误的屏幕截图。我试着用谷歌搜索但找不到任何英文解决方案
Edit : It seems like the screenshot's quality is low if i try to display it so here is the imgur link for the screenshot for better quality http://i.imgur.com/YYyoeUX.png
编辑:如果我尝试显示截图的质量似乎很低,所以这里是截图的 imgur 链接以获得更好的质量 http://i.imgur.com/YYyoeUX.png
回答by Paul Samsotha
Maven projects come with a bunch of plugins applied implicitly to the build. One of them being the maven-compiler-plugin
. Unfortunately the Java version for the plugin defaults to 1.5. Most Maven project you see will override the Java version simply by declaring the plugin (in your pom.xml file) and configuring the Java version
Maven 项目附带了一堆隐式应用于构建的插件。其中之一是maven-compiler-plugin
. 不幸的是,插件的 Java 版本默认为 1.5。您看到的大多数 Maven 项目将通过声明插件(在您的 pom.xml 文件中)并配置 Java 版本来覆盖 Java 版本
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.1</version>
<configuration>
<source>1.8</source>
<target>1.8</target>
</configuration>
</plugin>
</plugins>
</build>
Eclipse (with m2e plugin) will set the compiler compliance level to the setting in the plugin. You can view this by going to
Eclipse(带有 m2e 插件)会将编译器合规性级别设置为插件中的设置。您可以通过以下方式查看
Right click on the project -> properties -> Java Compiler -> Look at compliance level
项目右键->属性->Java编译器->查看合规级别
UPDATE
更新
Instead of the above compiler plugin configuration, you can also simply just do
除了上面的编译器插件配置,你也可以简单地做
<properties>
<maven.compiler.source>1.8</maven.compiler.source>
<maven.compiler.target>1.8</maven.compiler.target>
</properties>
The default plugin configuration will look for these properties. It's a lot less verbose than re-declaring the plugin.
默认插件配置将查找这些属性。它比重新声明插件要简洁得多。
>
>
回答by Claire
I know the topic is old but I had the same problem and it's hard to find informations on it. So set the properties wasn't enough for me, I had also to delete the project from Eclipse, then delete the .project file and reimport the project as a Maven project (even if I created it as a Maven project already) like it is answer on this topic.
我知道这个话题很旧,但我遇到了同样的问题,很难找到相关信息。因此,设置属性对我来说还不够,我还必须从 Eclipse 中删除该项目,然后删除 .project 文件并将该项目作为 Maven 项目重新导入(即使我已经将其创建为 Maven 项目),就像这样回答这个话题。
回答by ankit biswas
Just got to the path of the project and go to settings and find the xml file named "org.eclipse.wst.common.project.facet.core" and change the version of java from there
刚到项目的路径并转到设置并找到名为“org.eclipse.wst.common.project.facet.core”的xml文件并从那里更改java的版本
回答by Manish Sakariya
those who are doing with properties way and if it is not working do this step.
in Pom.xml
那些正在使用属性方式的人,如果它不起作用,请执行此步骤。
在 Pom.xml 中
<properties>
<maven.compiler.source>1.8</maven.compiler.source>
<maven.compiler.target>1.8</maven.compiler.target>
</properties>
After that do this:
之后这样做:
project folder-> maven--> update project--> check force update-->ok
After that do
在那之后做
project folder-->run as-->mvn build with goal eclipse:eclipse
you don't need to re-import the project as suggested in other answer/
您不需要按照其他答案中的建议重新导入项目/