10

我有一个 Maven 项目,它给出以下两个错误

无法安装 JAX-RS(REST Web 服务)2.0:一个或多个约束没有得到满足。
JAX-RS(REST Web 服务)2.0 需要 Java 1.7 或更高版本。

我安装了 JDK 1.6(我无法更改)

项目方面没有勾选 JAX-RS。

项目方面有 java 1.6 集。

项目方面具有 Dynamic Web Project 2.4 集。

我有以下插件

声纳 3.2.0 MercurialEclipse 2.10 EclEmma 2.2.1

pom.xml 就是这样...

<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
    <modelVersion>4.0.0</modelVersion>
    <groupId>com.fake.company</groupId>
    <artifactId>customerservice-war</artifactId>
    <version>2.0.0-SNAPSHOT</version>
</project>

web.xml 是

<?xml version="1.0" encoding="UTF-8"?>
<web-app version="2.4" xmlns="http://java.sun.com/xml/ns/j2ee"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd">
    <display-name>Customer Service</display-name>
</web-app>

清理或“更新 Maven 项目”没有区别。

注意:这是在 eclipse-jee-kepler-SR1-win32-x86_64 中。注意:版本 eclipse-jee-kepler-win32-x86_64 不会给出错误。

注意:新工作区不会更改错误。

Note: I'm using JDK.1.6.0_43

The only error I can see related to this in the ".log" file is..

!ENTRY org.eclipse.osgi 2 1 2013-10-16 15:07:58.816 !MESSAGE NLS unused message: JaxrsProjectConfigurator_The_project_does_not_contain_required_facets in: org.eclipse.m2e.wtp.jaxrs.internal.messages

Adding the facet, wont let me apply it since it says I need Java 1.7

JSR339 (JSR339) states "The API will make extensive use of annotations and will require J2SE 6.0 or later"

Any ideas?

4

4 回答 4

10

Delete the .project file and banish it from your source control. Instead of using Import -> Existing Project, use Import -> Maven project, and let m2e configure your Eclipse project.

于 2013-10-16T15:08:57.013 回答
9

It's a bug, fixed in Luna if not SR2. http://bugs.eclipse.org/416704

于 2013-10-16T15:21:36.723 回答
0

If the intention is to just get rid of these errors then you can simply right click on the errors in the "Marker View" and click delete.

于 2014-02-17T04:37:03.397 回答
0

I know you can't change your 1.6 JDK, but the following solution might help other people:

In my case, I have both JDK 1.6 and 1.7. I've tried several suggested solutions without any success.

Hence, in my pom.xml I changed from jdk 1.6 to jdk 1.7:

<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.0</version>
    <configuration>
        <source>1.7</source>
        <target>1.7</target>
    </configuration>
</plugin>

Using jdk 1.7 worked for me, although in my facets is setted the 1.6 (because my intention was use jdk 1.6).

于 2014-04-25T17:18:21.573 回答