Java – resteasy002142: multiple resource method matching requests

I'm following two completely different URLs, and I can't explain why:

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]

Since URLs are completely different, this warning should not appear If anyone knows why:

Website of two methods:

Getdevice for:

@GET
@Path("devices/{customerId}/{deviceids}")
@Produces({ "application/json" })

getDistinctValues:

@GET
@Path("devices/distinctValues/{customerId}")
@Consumes("application/json")
@Produces("application/json")

Solution

The warning occurs because your request string can match two path templates Request "devices / distinctvalues / 3"

>Match devices / distinguishvalues / {CustomerID} in CustomerID = "3" > match devices / {CustomerID} / {deviceids} in CustomerID = "distinguishvalues" and deviceids = "3"

There is no type resolution, and since your request is a string, you cannot tell CustomerID that it cannot accept "distinguishvalues"

As a solution, you can specify the regular expression displayed in the link problem, or use the resteasy proxy framework, which is basically the shared interface used by the server (your jax-rs resource) and the client, and then you have a type of common language resolution Please note that there is a spelling error in the document example

The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
分享
二维码
< <上一篇
下一篇>>