@Test public void testRestTemplate() { List<HttpMessageConverter<?>> messageConverters = restTemplate .getMessageConverters(); assertNotNull(messageConverters); assertTrue(messageConverters.size() == 1); HttpMessageConverter<?> messageConverter = messageConverters.get(0); assertNotNull(messageConverter); assertTrue(messageConverter instanceof MappingJacksonHttpMessageConverter); List<MediaType> mediaTypes = messageConverter.getSupportedMediaTypes(); assertNotNull(mediaTypes); assertTrue(mediaTypes.contains(MediaType.TEXT_HTML)); assertTrue(mediaTypes.contains(MediaType.APPLICATION_JSON)); ClientHttpRequestFactory requestFactory = restTemplate .getRequestFactory(); assertNotNull(requestFactory); }
@Bean RestTemplate restTemplate() { RestTemplate restTemplate = new RestTemplate(clientRequestFactory()); List<HttpMessageConverter<?>> messageConverters = new ArrayList<HttpMessageConverter<?>>(); messageConverters.add(jsonMessageConverter()); restTemplate.setMessageConverters(messageConverters); List<ClientHttpRequestInterceptor> interceptors = new ArrayList<ClientHttpRequestInterceptor>(); interceptors.add(new HttpRequestInterceptor()); restTemplate.setInterceptors(interceptors); return restTemplate; }
ClientConfig { @Bean RestTemplate restTemplate() { RestTemplate restTemplate = new RestTemplate(clientRequestFactory()); List<HttpMessageConverter<?>> messageConverters = new ArrayList<HttpMessageConverter<?>>(); messageConverters.add(jsonMessageConverter()); restTemplate.setMessageConverters(messageConverters); List<ClientHttpRequestInterceptor> interceptors = new ArrayList<ClientHttpRequestInterceptor>(); interceptors.add(new HttpRequestInterceptor()); restTemplate.setInterceptors(interceptors); return restTemplate; } }
ClientConfig { @Bean RestTemplate restTemplate() { RestTemplate restTemplate = new RestTemplate(clientRequestFactory()); List<HttpMessageConverter<?>> messageConverters = new ArrayList<HttpMessageConverter<?>>(); messageConverters.add(jsonMessageConverter()); restTemplate.setMessageConverters(messageConverters); List<ClientHttpRequestInterceptor> interceptors = new ArrayList<ClientHttpRequestInterceptor>(); interceptors.add(new HttpRequestInterceptor()); restTemplate.setInterceptors(interceptors); return restTemplate; }  }
ClientConfig { @Bean RestTemplate restTemplate() { RestTemplate restTemplate = new RestTemplate(clientRequestFactory()); List<HttpMessageConverter<?>> messageConverters = new ArrayList<HttpMessageConverter<?>>(); messageConverters.add(jsonMessageConverter()); restTemplate.setMessageConverters(messageConverters); List<ClientHttpRequestInterceptor> interceptors = new ArrayList<ClientHttpRequestInterceptor>(); interceptors.add(new HttpRequestInterceptor()); restTemplate.setInterceptors(interceptors); return restTemplate; }   }
ClientConfig { @Bean RestTemplate restTemplate() { RestTemplate restTemplate = new RestTemplate(clientRequestFactory()); List<HttpMessageConverter<?>> messageConverters = new ArrayList<HttpMessageConverter<?>>(); messageConverters.add(jsonMessageConverter()); restTemplate.setMessageConverters(messageConverters); List<ClientHttpRequestInterceptor> interceptors = new ArrayList<ClientHttpRequestInterceptor>(); interceptors.add(new HttpRequestInterceptor()); restTemplate.setInterceptors(interceptors); return restTemplate; }    }