Eclipse JAX-RS(REST Web服务)2.0需要Java 1.6或更高版本 [英] Eclipse JAX-RS (REST Web Services) 2.0 requires Java 1.6 or newer

查看:106
本文介绍了Eclipse JAX-RS(REST Web服务)2.0需要Java 1.6或更高版本的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是Web服务的新手,我正在尝试使用jax-rs rest和eclipse中的spring做一个项目. 我使用Java 1.8,但是eclipse向我显示了一个错误,表明jax-rs 2.0需要Java 1.6或更高版本的错误,并且我的项目无法正常工作

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

这是项目资源管理器和错误的屏幕截图.我试图用Google搜索它,但没有任何英语解决方案

This is the project explorer and error's screenshot. I tried to google it but can't get any english solutions

如果我尝试显示屏幕截图,则屏幕截图的质量似乎很低,因此,这是屏幕截图的imgur链接,以获得更好的质量 http://i.imgur.com/YYyoeUX.png

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

推荐答案

Maven项目附带了许多隐式应用于构建的插件.其中之一是maven-compiler-plugin.不幸的是,该插件的Java版本默认为1.5.您看到的大多数Maven项目都将通过声明插件(在pom.xml文件中)并配置Java版本来覆盖Java版本

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

  <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(带有m2e插件)会将编译器的遵从性级别设置为插件中的设置.您可以通过以下方法查看

Eclipse (with m2e plugin) will set the compiler compliance level to the setting in the plugin. You can view this by going to

右键单击该项目->属性-> Java编译器->看看合规水平

Right click on the project -> properties -> Java Compiler -> Look at compliance level

更新

除了上面的编译器插件配置,您还可以简单地做

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.

在将属性或编译器插件添加到pom.xml之后,您可能需要更新项目.参见 Manish的答案.

After adding the properties or the compiler plugin to your pom.xml, you might need to update the project. See Manish's answer.

这篇关于Eclipse JAX-RS(REST Web服务)2.0需要Java 1.6或更高版本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆