OAuth2RestTemplate.postForEntity RestClientException:[org.x.xx]和内容类型[application / json]

时间:2019-04-25 14:09:10

标签: java spring spring-boot resttemplate oauth2resttemplate

我正在使用OAuth2RestTemplate查询接受JSON对象的外部api。

HttpHeaders headers = new HttpHeaders();
headers.add(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON_VALUE);
HttpEntity<XX> request = new HttpEntity<>(xX, headers);
ResponseEntity<String> response = oAuth2RestTemplate.postForEntity(url , request, String.class);

我收到此错误:

org.springframework.web.client.RestClientException: No HttpMessageConverter for [com.yy.XX] and content type [application/json]
    at org.springframework.web.client.RestTemplate$HttpEntityRequestCallback.doWithRequest(RestTemplate.java:956) ~[spring-web-5.1.4.RELEASE.jar:5.1.4.RELEASE]
    at org.springframework.web.client.RestTemplate.doExecute(RestTemplate.java:732) ~[spring-web-5.1.4.RELEASE.jar:5.1.4.RELEASE]

我试图将MappingJackson2HttpMessageConverter添加到我的oAuth2RestTemplate中,但是出现了同样的错误。

0 个答案:

没有答案