jersey服务器请求资源不可用-404错误

时间:2020-06-16 06:37:53

标签: tomcat get http-status-code-404 jersey-2.0

我正在使用Jersey 2.7创建其余的Web服务。这是相关的pom.xml文件:

        <dependency>
            <groupId>org.glassfish.jersey.media</groupId>
            <artifactId>jersey-media-json-jackson</artifactId>
        </dependency>

        <dependency>
            <groupId>org.glassfish.jersey.core</groupId>
            <artifactId>jersey-server</artifactId>
            <version>2.27</version>
        </dependency>
        <dependency>
            <groupId>org.glassfish.jersey.containers</groupId>
            <artifactId>jersey-container-servlet</artifactId>
            <version>2.27</version>
        </dependency>
        <dependency>
            <groupId>org.glassfish.jersey.inject</groupId>
            <artifactId>jersey-hk2</artifactId>
            <version>2.27</version>
        </dependency>

和应用程序类:

@ApplicationPath("rest")
public class Application extends ResourceConfig {
    public Application() {
        this.packages("com.my.packge");
    }
}

和api类:

@Path("/api")
public class myApi {

    @GET
    @Consumes(MediaType.TEXT_PLAIN)
    @Path("/test")
    public String test(){
        return "I'm here!";
    }
}

我使用tomcat运行程序,结果如下:

Message The requested resource [/rest/api/test2] is not available

Description The origin server did not find a current representation for the target resource or is not willing to disclose that one exists.

0 个答案:

没有答案