Change message converter to Gson in RestTemplate

Message converters are used to convert the Http request to an object representation and back.

RestTemplate restTemplate = new RestTemplate();
         
List<HttpMessageConverter<?>> messageConverters = new ArrayList<>();
GsonHttpMessageConverter gsonHttpMessageConverter = new GsonHttpMessageConverter();
messageConverters.add(gsonHttpMessageConverter);
restTemplate.setMessageConverters(messageConverters);

No comments:

Post a Comment