RestTemplate:
- The original synchronous, blocking HTTP client.
- Still supported but in maintenance mode; no new features.
WebClient:
- Non-blocking, reactive client from Spring WebFlux, returning Mono and Flux.
- Best when the application is reactive end to end, or when you need many concurrent calls with few threads.
- Can be used in a blocking app with .block(), but that loses the benefit and adds the WebFlux dependency.
RestClient (Spring Framework 6.1, Boot 3.2):
- A modern synchronous client with a fluent API similar to WebClient, built on the same infrastructure as RestTemplate.
- The recommended choice for new blocking (Spring MVC) applications.
HTTP interfaces:
- Declare an interface with @GetExchange / @PostExchange and let Spring generate the client, backed by RestClient or WebClient, similar to Feign.
Whatever the client:
- Configure connect and read timeouts explicitly.
- Reuse a configured client bean (connection pooling) rather than creating one per call.
- With Java 21 virtual threads (spring.threads.virtual.enabled=true), blocking clients scale well too.