我将这一切都在一个webapp中工作,而不是与另一个人合作,并且不能为我的生活看到有什么区别。
RESTeasy 3.0.16(也尝试过3.0.13) Tomcat 7.0.67
库:resteasy-servlet-initializer,resteasy-jaxrs,resteasy-jackson2-provider
的web.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>
ServiceApplication.java
@ApplicationPath("/api")
public class ServiceApplication extends Application { }
ServiceInterface.java
public interface ServiceInterface {
@GET
@Path("/ping")
@Produces(MediaType.TEXT_HTML)
public Response ping();
}
Service.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异常。
答案 0 :(得分:0)
在发布之后(在花了3天之后......),你是不是总能找到答案的方式。
Service.java错了。它必须是:
@Path("/")
public class Service implements ServiceInterface, Serializable {
@Override
public Response ping() {
return noCacheResponseBuilder(Response.Status.OK).entity("PING").build();
}
}