RestTemplate
- 동기(Synchronous) 방식 : 요청을 보낸 후 응답이 돌아올 때까지 블로킹
- API 호출이 간단하고 동기적인 응답이 필요한 경우 적합
- 단순하고 사용하기 쉬움
WebClient
- 비동기(Asynchronous), 리액티브
- 비동기로 요청을 처리하여 더 높은 처리 성능
- SpringBoot 5+에서 공식적으로 권장
- 리액티브 방식으로 코드가 다소 복잡할 수 있음
RestTemplate
의 deprecated에 대해 이런 저런 이슈가 있었던 모양이지만, 현재는 maintenance mode를 유지중이다.참고로, Spring 6.x 버전의
RestTemplate
클래스의 주석에 따르면 RestTemplate
andRestClient
share the same infrastructure (i. e. request factories, request interceptors and initializers, message converters, etc.), so any improvements made therein are shared as well. However,RestClient
is the focus for new higher-level features.
RestTemplate
과 RestClient
는 동일한 인프라(예: 요청 팩토리, 요청 인터셉터 및 초기화 프로그램, 메시지 변환기 등)를 공유하기 때문에 적용되는 개선 사항은 모두 공유되지만, RestClient
가 좀 더 고수준의 기능에 초점을 맞추고 있다고 한다. 그렇기 때문에 아주 간단한 코드 작성이나 기존에 이미 RestTemplate
으로 작성되어 있는 경우가 아니라면 장기적으로는 모던한 RestClient
를 사용하는 것이 권고되는 것 같다.