我建立了分離的休息模型庫,當球衣做資源配置包,似乎不起作用,它會響應請求的資源不可用。JAX-RS與澤西2.22.2 + Tomcat 7.0.59:請求的資源不可用
我用:新澤西2.22.2和Tomcat 7.0.59
並請在下面找到以下資料:
rest-model.jar (file)
> com.company.rest.domain.* (package)
> TestData.class (file)
> @XmlRootElement
> class TestData {
> private String str ;
> public TestData() {}
> public TestData(String str) { setStr(str); }
> public String getStr() { return str ; }
> public void setStr(String str) { this.str = str ; }
> }
> com.company.rest.service.* (package)
> TestService.class (file)
> @Path("/test")
> @Produces({MediaType.APPLICATION_JSON})
> class TestService {
> @GET public TestData test() {
> return new TestData("test") ;
> }
> }
Tomcat with classpath to file rest-model.jar
WebRoot (folder)
> WEB-INF (folder)
> web.xml (file)
<servlet>
<servlet-name>RestApp</servlet-name>
<servlet-class>
org.glassfish.jersey.servlet.ServletContainer
</servlet-class>
<init-param>
<param-name>
com.sun.jersey.config.property.packages
</param-name>
<param-value>
com.company.rest.service
</param-value>
</init-param>
</servlet>
<servlet-mapping>
<servlet-name>RestApp</servlet-name>
<url-pattern>/rest/*</url-pattern>
</servlet-mapping>
嘗試通過'com.sun.jersey.spi.container.servlet.ServletContainer'更換你的servlet類。 – nnunes10