我的Web.xml如下:
<?xml version="1.0" encoding="UTF-8"?>
<web-app version="3.1" xmlns="http://xmlns.jcp.org/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/web-app_3_1.xsd">
<servlet-mapping>
<servlet-name>javax.ws.rs.core.Application</servlet-name>
<url-pattern>/rest/*</url-pattern>
</servlet-mapping>
</web-app>
我的应用程序配置类如下:
@ApplicationPath("/api/catalogManagement/v2")
public class ApplicationConfig extends ResourceConfig
我的休息服务课程如下:
@Stateless
@Path("/catalog")
public class CatalogFacadeREST extends AbstractFacadeREST<CatalogEntity> {
@GET
@Produces({MediaType.APPLICATION_JSON})
public Response find(@QueryParam("depth") int depth, @Context UriInfo uriInfo) throws BadUsageException {
}
}
我打电话给这个休息服务:http://localhost:8080/DSPRODUCTCATALOG2/rest/api/catalogManagement/v2/catalog?depth=5
但我得到了:
21:17:53,739 ERROR [org.jboss.resteasy.resteasy_jaxrs.i18n] (default task-1) RESTEASY002010: Failed to execute: javax.ws.rs.NotFoundException: RESTEASY003210: Could not find resource for full path: http://localhost:8080/DSPRODUCTCATALOG2/rest/api/catalogManagement/v2/catalog?depth=5
at org.jboss.resteasy.core.registry.ClassNode.match(ClassNode.java:75)
at org.jboss.resteasy.core.registry.RootClassNode.match(RootClassNode.java:48)
at org.jboss.resteasy.core.ResourceMethodRegistry.getResourceInvoker(ResourceMethodRegistry.java:445)
答案 0 :(得分:0)
我认为这是问题所在:
@ApplicationPath("/api/catalogManagement/v2")
应该是,没有前导斜杠
@ApplicationPath("api/catalogManagement/v2")
答案 1 :(得分:0)
您的配置当然存在一些问题。您不必添加
<servlet-mapping>
<servlet-name>javax.ws.rs.core.Application</servlet-name>
<url-pattern>/rest/*</url-pattern>
</servlet-mapping>
在你的web .xml中作为javax.ws.rs.core.Application根本不是一个servlet。相反,你必须像这样配置;
@ApplicationPath("/<your path>")
public class ApplicationReSTService extends Application {
}
对你的相对路径给出斜线也没有问题。
答案 2 :(得分:0)
我想您已经在Application类(或Config类)中重写了“ getClasses”方法。结果,如果这些类不存在,则看不到配置...