我正在关注两个完全不同的URL,我无法解释为什么:
RESTEASY002142:
Multiple resource methods match request "GET /devices/distinctValues/3".
Selecting one.
Matching methods:
[public javax.ws.rs.core.Response
mypackage.DevService.getDistinctValues(int) throws java.lang.Exception,
public javax.ws.rs.core.Response
mypackage.DevRESTService.getDevice(int,java.lang.String)
throws java.lang.Exception]
这个警告不应该出现,因为URLS完全不同。如果有人知道为什么会这样:
这两种方法的URL:
getDevice
@GET
@Path("devices/{customerId}/{deviceIds}")
@Produces({ "application/json" })
getDistinctValues
@GET
@Path("devices/distinctValues/{customerId}")
@Consumes("application/json")
@Produces("application/json")
发布于 2017-09-19 08:40:47
出现此警告是因为您的请求字符串可以匹配两个路径模板。请求"devices/distinctValues/3"
devices/distinctValues/{customerId}
在customerId = "3"
中匹配devices/{customerId}/{deviceIds}
在customerId = "distinctValues"
和deviceIds = "3"
中匹配。没有类型解析,因为您的请求是String
,所以无法告诉customerId
它不能接受"distinctValues"
。
作为解决办法,您可以指定regex,如链接问题中所示,或者使用RESTEasy代理框架,它基本上是服务器(您的JAX-RS资源)和客户端使用的共享接口,然后您就有了一种类型解析的通用语言。注意,在文档示例中有一个错误。
https://stackoverflow.com/questions/46081787
复制相似问题