我正在使用带有杰克逊提供者的 RestEasy 客户端并收到上述错误
客户端代码是:
ClientRequest request = new ClientRequest(url);
request.accept(MediaType.APPLICATION_JSON);
ClientResponse<String> response = request.get(String.class);
if (response.getStatus() != 200) {
throw new RuntimeException("Failed : HTTP error code : " + response.getStatus());
}
BufferedReader br =
new BufferedReader(new InputStreamReader(new ByteArrayInputStream(response.getEntity().getBytes())));
response.getEntity()
正在抛出ClientResponseFailure
异常,错误为
Unable to find a MessageBodyReader of content-type application/json and type class java.lang.String
我的服务器端代码如下:
@GET
@Path("/{itemId}")
@Produces(MediaType.APPLICATION_JSON)
public String item(@PathParam("itemId") String itemId) {
//custom code
return gson.toJSON(object);
}