DEV Community

Mac
Mac

Posted on

Spring Boot : RestTemplate

Spring Boot does not provide auto-configured RestTemplate bean but we can create it by

1.) Initialize RestTemplate

@Bean
public RestTemplate restTemplate() {
    return new RestTemplate();
}

2.) Using RestTemplateBuilder

@Bean
public RestTemplate restTemplate(RestTemplateBuilder restTemplateBuilder) {
    return restTemplateBuilder.build();
}

CRUD Operation on RestTemplate

restTemplate.getForEntity();
restTemplate.postForEntity();
restTemplate.put();
restTemplate.delete();

Top comments (0)