RestTemplate.exchage ( ) 메소드

ResponseEntity<String> responseEntity = 
this.restTemplate.exchange(
makeUri(), method, request, String.class
);

RestTemaplte 사용방법

스프링 RestTemplate

RestTemplate.exchage( )

사용방법

@Test
public void test_exchange() {
   HttpHeaders headers = new HttpHeaders();
   headers.setContentType(MediaType.APPLICATION_JSON);
   HttpEntity<String> request = new HttpEntity<>("Hello World!", headers);
   log.info("request: {}", request);
 
   ResponseEntity<Employee> empEntity = restTemplate.exchange(BASE_URL + "/exchange/employee/{id}", HttpMethod.GET, request, Employee.class, 50);
   log.info("empEntity: {}", empEntity);
}