我正在使用JAXRS客户端连接到我的服务器。在幸福的道路上,这可以正常工作,但是当我的服务器抛出异常时,客户端会收到Caused by: javax.ws.rs.NotAcceptableException: HTTP 406 Not Acceptable
My Client Code is:
public interface ConfigClient {
@PUT
@Produces(MediaType.APPLICATION_JSON)
@Consumes(MediaType.APPLICATION_JSON)
@Path("/testMe")
Map<String, Object> saveAttributeStore(MyInput myInput);
}
public ConfigClient create(String url) {
final ResponseExceptionMapper exceptionMapper = response -> new RuntimeException();
final List<Object> providers = List.of(new JacksonJsonProvider(), exceptionMapper);
ConfigClient configClient = JAXRSClientFactory.create(url, ConfigClient.class, providers);
HTTPClientPolicy clientPolicy = WebClient.getConfig(configClient).getHttpConduit().getClient();
clientPolicy.setReceiveTimeout(1000);
clientPolicy.setConnectionTimeout(3000);
return configClient;
}
And Server Endpoint is:
@PutMapping(path = "testMe",
consumes = MediaType.APPLICATION_JSON_VALUE,
produces = MediaType.APPLICATION_JSON_VALUE)
public Map<String, Object> createAttributeStore(MyInput input) {
return null;
}