resteasy 3.0.16缺少某些内容(resteasy003210)

drnojrws  于 2021-07-13  发布在  Java
关注(0)|答案(1)|浏览(281)

我在一个webapp中工作,而不在另一个webapp中工作,我一辈子都看不出有什么区别。
resteasy 3.0.16(也尝试了3.0.13)tomcat 7.0.67
库:resteasyservlet初始值设定项、resteasyjaxrs、resteasy-jackson2-provider
网站.xml

<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xmlns="http://java.sun.com/xml/ns/javaee" 
    xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
    xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
    id="WebApp_ID" 
    version="2.5">

    <display-name>REST Service</display-name>
</web-app>

服务应用程序.java

@ApplicationPath("/api")
public class ServiceApplication extends Application { }

服务接口.java

public interface ServiceInterface {
     @GET
     @Path("/ping")
     @Produces(MediaType.TEXT_HTML)
     public Response ping();
}

服务.java

public class Service implements ServiceInterface, Serializable {    
    @Override
    public Response ping() {
        return NoCacheResponseBuilder(Response.Status.OK).entity("PING").build();
    }

打电话http://localhost:8080/webapp/api/ping导致resteasy003210异常。

8iwquhpp

8iwquhpp1#

你不是总是在发完帖子后(花了3天的时间)才找到答案吗
service.java出错。它需要:

@Path("/")
public class Service implements ServiceInterface, Serializable {

    @Override
    public Response ping() {
        return noCacheResponseBuilder(Response.Status.OK).entity("PING").build();
    }
}

相关问题