使用Maven时的合规性错误

时间:2016-12-13 17:07:36

标签: java rest maven

<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.sumit.jaxrs</groupId>
<artifactId>advanced-jaxrs</artifactId>
<packaging>war</packaging>
<version>0.0.1-SNAPSHOT</version>
<name>advanced-jaxrs Maven Webapp</name>
<url>http://maven.apache.org</url>
<dependencies>
    <dependency>
        <groupId>org.glassfish.jersey.bundles</groupId>
        <artifactId>jaxrs-ri</artifactId>
        <version>2.16</version>
    </dependency>
    <dependency>
        <groupId>org.glassfish.jersey.media</groupId>
        <artifactId>jersey-media-moxy</artifactId>
        <version>2.16</version>
    </dependency>
</dependencies>
<build>
    <finalName>advanced-jaxrs</finalName>

    <plugins>
        <plugin>
        <!-- for changing the compiler to 1.8 -->
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-dependency-plugin</artifactId>
            <version>2.5.1</version>
            <inherited>true</inherited>
            <configuration>
                <source>1.8</source>
                <target>1.8</target>
            </configuration>
        </plugin>
    </plugins>
</build>

<properties>
    <jersey-version>2.16</jersey-version>
    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>

Java compiler level does not match the version of the installed Java project         facet.
JAX-RS (REST Web Services) 2.0 can not be installed : One or more constraints have not been satisfied.
JAX-RS (REST Web Services) 2.0 requires Java 1.6 or newer.

以下是我为虚拟webapp REST创建的文件。

import javax.ws.rs.ApplicationPath;
import javax.ws.rs.core.Application;

@ApplicationPath("webapi")
public class MyApp extends Application{
}

其他文件是:

import javax.ws.rs.GET;
import javax.ws.rs.Path;
import javax.ws.rs.Produces;
import javax.ws.rs.core.MediaType;

@Path("test")
public class MyResource {

@GET
@Produces(MediaType.TEXT_PLAIN)
public String getMessage(){
    return "It Worked";
   }
}

我正在使用1.8.101 jdk。任何人都可以告诉我为什么会收到上述错误。可能是因为我通过Maven将编译器级别从1.5更改为1.8? 该项目是maven webapp archtype

0 个答案:

没有答案