我正在使用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中,但是出现了同样的错误。