@Test public void testRestTemplate() throws Exception { String url = "http: ResponseEntity<Map> entity = RestClient.getInstance().restTemplate().getForEntity(url, Map.class); assertTrue(entity.getStatusCode().equals(HttpStatus.OK)); assertEquals("Hello!", entity.getBody().get("message")); System.out.println("message = " + entity.getBody().get("message")); }
public RestTemplate restTemplate() throws Exception { if(restTemplate == null) { synchronized (RestClient.class) { if(restTemplate == null) { restTemplate = new RestTemplate(httpRequestFactory()); List<HttpMessageConverter<?>> converters = restTemplate .getMessageConverters(); for (HttpMessageConverter<?> converter : converters) { if (converter instanceof MappingJackson2HttpMessageConverter) { MappingJackson2HttpMessageConverter jsonConverter = (MappingJackson2HttpMessageConverter) converter; jsonConverter.setObjectMapper(ServiceLocator.getInstance().getMapper()); } } } } } return restTemplate; }
RestClient { public RestTemplate restTemplate() throws Exception { if(restTemplate == null) { synchronized (RestClient.class) { if(restTemplate == null) { restTemplate = new RestTemplate(httpRequestFactory()); List<HttpMessageConverter<?>> converters = restTemplate .getMessageConverters(); for (HttpMessageConverter<?> converter : converters) { if (converter instanceof MappingJackson2HttpMessageConverter) { MappingJackson2HttpMessageConverter jsonConverter = (MappingJackson2HttpMessageConverter) converter; jsonConverter.setObjectMapper(ServiceLocator.getInstance().getMapper()); } } } } } return restTemplate; } }
RestClient { public RestTemplate restTemplate() throws Exception { if(restTemplate == null) { synchronized (RestClient.class) { if(restTemplate == null) { restTemplate = new RestTemplate(httpRequestFactory()); List<HttpMessageConverter<?>> converters = restTemplate .getMessageConverters(); for (HttpMessageConverter<?> converter : converters) { if (converter instanceof MappingJackson2HttpMessageConverter) { MappingJackson2HttpMessageConverter jsonConverter = (MappingJackson2HttpMessageConverter) converter; jsonConverter.setObjectMapper(ServiceLocator.getInstance().getMapper()); } } } } } return restTemplate; } private  RestClient(); }
RestClient { public RestTemplate restTemplate() throws Exception { if(restTemplate == null) { synchronized (RestClient.class) { if(restTemplate == null) { restTemplate = new RestTemplate(httpRequestFactory()); List<HttpMessageConverter<?>> converters = restTemplate .getMessageConverters(); for (HttpMessageConverter<?> converter : converters) { if (converter instanceof MappingJackson2HttpMessageConverter) { MappingJackson2HttpMessageConverter jsonConverter = (MappingJackson2HttpMessageConverter) converter; jsonConverter.setObjectMapper(ServiceLocator.getInstance().getMapper()); } } } } } return restTemplate; } private  RestClient(); static RestClient getInstance(); RestTemplate restTemplate(); AsyncRestTemplate asyncRestTemplate(); }
RestClient { public RestTemplate restTemplate() throws Exception { if(restTemplate == null) { synchronized (RestClient.class) { if(restTemplate == null) { restTemplate = new RestTemplate(httpRequestFactory()); List<HttpMessageConverter<?>> converters = restTemplate .getMessageConverters(); for (HttpMessageConverter<?> converter : converters) { if (converter instanceof MappingJackson2HttpMessageConverter) { MappingJackson2HttpMessageConverter jsonConverter = (MappingJackson2HttpMessageConverter) converter; jsonConverter.setObjectMapper(ServiceLocator.getInstance().getMapper()); } } } } } return restTemplate; } private  RestClient(); static RestClient getInstance(); RestTemplate restTemplate(); AsyncRestTemplate asyncRestTemplate();  }