Quick revision
The short answer
The history shows that client APIs change roughly once a decade, and AsyncRestTemplate has already been removed, so application code should depend on a specific client API as little as possible. Code that calls the client directly at hundreds of sites is expensive to migrate, while code that calls small typed interfaces per dependency, declarative clients or adapters, with all cross-cutting configuration in one place, can swap clients locally. We should plan such migrations as routine maintenance rather than rare large projects.
What to remember
In this answer, we used the history of Spring's HTTP clients, RestTemplate, AsyncRestTemplate, WebClient, HTTP interfaces and RestClient, to draw lessons about dependencies. Client APIs change about once a decade and old ones get removed, so direct calls from hundreds of sites are expensive to migrate. Hiding each dependency behind a small typed interface or declarative client, keeping cross-cutting configuration in one place, and treating migrations as routine maintenance turn the next client change into a local, low-risk task.
Your turn
Answer it aloud as you would in the interview, or type your answer below. Then show one part at a time and compare.
The history shows that client APIs change roughly once a decade, and AsyncRestTemplate has already been removed, so application code should depend on a specific client API as little as possible. Code that calls the client directly at hundreds of sites is expensive to migrate, while code that calls small typed interfaces per dependency, declarative clients or adapters, with all cross-cutting configuration in one place, can swap clients locally. We should plan such migrations as routine maintenance rather than rare large projects.
Why this question is asked
Spring's HTTP clients are a useful case study because the whole history is visible: RestTemplate in 2009, AsyncRestTemplate, WebClient with the reactive stack, RestClient in 2023, and HTTP interfaces alongside. Each change had good reasons, and each left codebases with hundreds of call sites to update. Interviewers ask this at a very senior level to hear what we learned about dependencies in general, not just about Spring. In this answer, we will review the timeline, see why direct calls are expensive, describe the design that makes a client swap local, show where configuration belongs, and turn migrations into routine work.
1A Short History of Spring's HTTP Clients
RestTemplate came with Spring 3.0 in 2009, a template class in the style of JdbcTemplate. AsyncRestTemplate followed in Spring 4.0 for non-blocking calls returning futures; it was deprecated in Spring 5.0 in favour of WebClient and is gone in Spring 6. WebClient arrived with WebFlux in Spring 5.0 in 2017 and became the recommended fluent client even for many blocking applications. HTTP interfaces came in Spring 6.0 and RestClient in 6.1, in 2023, which in turn puts RestTemplate into maintenance mode with a deprecation announced for a future release.
Notice the pattern. Each new client reflected a change in how Java applications were written: templates, then futures, then reactive streams, then fluent blocking calls that pair well with virtual threads. None of these changes was a mistake, and the next one will not be either. So the question is not how to pick the client that will last forever, but how to make the next change cheap.
| Client | Introduced | Status now |
|---|---|---|
RestTemplate | Spring 3.0, 2009 | Maintenance mode, deprecation announced |
AsyncRestTemplate | Spring 4.0, 2013 | Deprecated in 5.0, removed in 6.0 |
| WebClient | Spring 5.0, 2017 | Current reactive client |
| HTTP interfaces | Spring 6.0, 2022 | Current declarative layer |
RestClient | Spring 6.1, 2023 | Current synchronous client |
2Why Direct Calls Are Expensive to Migrate
When business code calls restTemplate.getForObject directly, each call site mixes three things: what we want (the payment with id 9), how HTTP expresses it (a URI template, headers), and the specific client API. A migration must touch all of them at every site. With 300 sites, that is 300 small changes, each with its own error handling and test gaps, spread across teams.
The cost is not the typing. It is that every site is a chance to change behaviour by accident, for example how a 404 is handled, and that the work competes with features for months. Teams that went through the AsyncRestTemplate removal or a Feign-to-WebClient move know this pain well.
3Hiding Outbound Calls Behind Small Typed Interfaces
The design lesson is to give each downstream dependency one small interface in our own terms, and let only one class know which client API implements it. The interface can be a declarative HTTP interface, where Spring generates the implementation, or a plain port with a hand-written adapter.
Now 40 business classes that need payments call PaymentsGateway, and only one class mentions RestClient. When the next client API arrives, we write one new adapter, run the same contract tests against it, and switch the bean. The business code does not change at all. Notice also that error semantics, such as 404 meaning empty, are decided once in the adapter rather than reinvented at every call site.
4Keeping Cross-Cutting Configuration in One Place
The second half of the lesson is configuration. Timeouts, connection pools, retries, tracing, metrics and authentication are the same concerns whatever client we use. If they are spread across call sites, a client swap means rediscovering all of them. If they live in a small number of bean definitions, or better in a company starter that configures every outbound client the same way, a swap means changing those definitions only.
So a healthy codebase has three layers: business code calling typed interfaces, adapters or generated clients implementing them, and a configuration layer that builds the underlying client with all the cross-cutting settings. Only the last two layers know which client API is in use.
- Business codecalls
PaymentsGateway, never a client API - Typed interfacesone per dependency, in our own terms
- Adapters or HTTP interfacesthe only code that uses
RestClientor WebClient - Client configurationtimeouts, pools, auth, tracing in one place or a starter
4 layers, from the top down. Step through them one at a time.
5Treating Migrations as Routine Maintenance
Even with good boundaries, migrations will come, and the last lesson is about how we plan them. If we migrate only when forced, every migration is a rare, large, risky project with a deadline set by someone else. If we treat library and API upgrades as routine, a small, continuous share of each team's time, they stay small: a new client API is adopted for new code soon after it appears, and existing adapters move over steadily.
In practice that means a few habits: a maintenance budget in every planning cycle, guardrails such as ArchUnit rules that stop new usage of APIs on their way out, a dashboard of deprecated usages per team, and leaders who count finished migrations as real work. A company that does this barely notices the next change in Spring's client APIs.
6Follow-up questions
Is an extra interface per dependency over-engineering?
For a service called from one place, a declarative HTTP interface is already that interface and costs almost nothing. For services called from many places, a typed boundary pays for itself in the first migration, and also makes testing easier, because business code can be tested with a fake implementation instead of a mocked HTTP server.
Does this lesson apply beyond HTTP clients?
Yes. The same pattern applies to messaging clients, cloud SDKs, caches and AI model APIs, which change even faster. Any third-party API called from hundreds of places becomes a migration problem; any API hidden behind a small interface becomes a local change.
7Conclusion
In this answer, we used the history of Spring's HTTP clients, RestTemplate, AsyncRestTemplate, WebClient, HTTP interfaces and RestClient, to draw lessons about dependencies. Client APIs change about once a decade and old ones get removed, so direct calls from hundreds of sites are expensive to migrate. Hiding each dependency behind a small typed interface or declarative client, keeping cross-cutting configuration in one place, and treating migrations as routine maintenance turn the next client change into a local, low-risk task.
Open with
The history is quite telling. RestTemplate came in 2009, AsyncRestTemplate in Spring 4 and it was already deprecated in 5 and removed in 6, WebClient in 2017 with WebFlux, HTTP interfaces in 6.0 and RestClient in 6.1, which in turn puts RestTemplate into maintenance mode.
Then, if they want more
So roughly every decade the recommended client changes, for good reasons each time, and I expect that to continue. The lesson I take is that business code should not depend on the client API directly. When hundreds of sites call restTemplate.getForObject, each migration is hundreds of small risky changes, mostly around error handling.
Instead I give each downstream dependency one small typed interface in our own terms, either a declarative HTTP interface or a port with one adapter, and only that adapter knows whether it uses RestClient or WebClient. Error semantics like treating 404 as empty are decided once there.
Cross-cutting configuration, timeouts, pools, auth, tracing, lives in a few bean definitions or a company starter, so a swap changes one place.
And I plan migrations as routine maintenance: a small regular budget, ArchUnit rules to stop new usage of outgoing APIs, and a dashboard of deprecated usages, so each change stays small instead of becoming a big project with someone else's deadline.
About this answer
- Last updated
- 12 November 2026
- Checked
- Its structure and format are checked automatically. Use it as a carefully prepared study note: where a detail matters, confirm it against the documentation below. What the checks cover
- Where the question comes from
- Written by Scrivio for practice. It is not taken from an interview.
- Official documentation
- Spring Framework reference, Spring Web MVC
Report an issue with this answer
Copy the line below and send it to the author with what you found. It carries the address of this page.
Issue with "Spring has introduced several HTTP client APIs over the years (RestTemplate...": https://scrivio-interview-library.netlify.app/spring-boot/http-clients/a5a5c9b74d/