RestClient (Spring 6.1+) is the modern fluent, synchronous HTTP client — WebClient's ergonomics without needing Reactor. It's the forward path for blocking HTTP calls; RestTemplate is in maintenance mode (still supported, not formally deprecated) but won't get new features.
Why it exists
RestTemplate works but its API is template-method-style and awkward for anything beyond simple getForObject. WebClient has a much nicer fluent API but pulls in the reactive stack and returns Mono/Flux, which is overkill if your code is plain blocking. RestClient takes WebClient's fluent, chained API and makes it synchronous — you get the readable builder style and direct return values.
RestClient client = RestClient.create("https://orders.internal");
Order order = client.get()
.uri("/orders/{id}", 42)
.accept(MediaType.APPLICATION_JSON)
.retrieve()
.body(Order.class); // blocks, returns the value directly
POST and error handling read naturally:
Order created = client.post()
.uri("/orders")
.body(new NewOrder("widget"))
.retrieve()
.onStatus(HttpStatusCode::is4xxClientError,
(req, res) -> { throw new OrderClientException(res.getStatusCode()); })
.body(Order.class);
For full control, .toEntity(Order.class) returns a ResponseEntity; .exchange(...) hands you the raw request/response.
Status in the ecosystem
- It reuses the same
ClientHttpRequestFactoryinfrastructure asRestTemplate, so you can migrate incrementally and even build aRestClientfrom an existingRestTemplate. - It backs
@HttpExchangeinterfaces viaRestClientAdapter, so declarative clients can run on a blocking transport. RestTemplateis not deprecated — existing code keeps working — but new code should preferRestClient. State this precisely; claimingRestTemplateis "deprecated" is a common but wrong answer.