Quick revision
The short answer
Both are annotated interfaces, so the programming model is almost the same and simple interfaces migrate with an almost one to one mapping of annotations. Spring's HTTP interface clients integrate with Spring configuration, Micrometer observation, Spring's error handling and message converters, while Retrofit with OkHttp is mature, also works on Android and has a large ecosystem of call adapters. Running two HTTP stacks doubles the configuration of timeouts, pools, TLS and tracing, so I would usually move a Spring Boot service to RestClient-backed interfaces, deciding by the platform standard and observability needs, and keep Retrofit where the client code is shared with Android.
What to remember
In this answer, we saw that Retrofit and Spring's HTTP interface clients share the same annotated-interface model, with annotations mapping almost one to one and error handling as the real difference. Spring's version integrates with Boot configuration, Micrometer observation, message converters and Spring's exceptions; Retrofit with OkHttp is mature, Android-friendly and rich in call adapters. Two HTTP stacks double the configuration of timeouts, pools, TLS and tracing, so we migrate a Spring Boot backend gradually when the platform standard and observability needs point to RestClient, and keep Retrofit where code is shared with Android.
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.
Both are annotated interfaces, so the programming model is almost the same and simple interfaces migrate with an almost one to one mapping of annotations. Spring's HTTP interface clients integrate with Spring configuration, Micrometer observation, Spring's error handling and message converters, while Retrofit with OkHttp is mature, also works on Android and has a large ecosystem of call adapters. Running two HTTP stacks doubles the configuration of timeouts, pools, TLS and tracing, so I would usually move a Spring Boot service to RestClient-backed interfaces, deciding by the platform standard and observability needs, and keep Retrofit where the client code is shared with Android.
Why this question is asked
Many Spring Boot teams adopted Retrofit before Spring had a declarative client of its own, because Feign meant Spring Cloud and Retrofit was simple and solid. Now that Spring Framework ships HTTP interface clients, those teams ask whether to switch. Interviewers ask this design question to see whether we can compare two good tools by what they cost to run in a specific context, rather than by which is newer. In this answer, we will compare the programming models, look at what Spring integration gives us, at Retrofit's strengths, at the cost of two HTTP stacks, estimate the migration, and decide.
1Two Very Similar Programming Models
Retrofit and Spring's HTTP interface clients share an idea: describe the remote API as a Java interface with annotations, and let the library generate the implementation. The annotations map closely, which is what makes comparison and migration easy.
| Retrofit | Spring HTTP interface |
|---|---|
@GET("users/{id}") | @GetExchange("/users/{id}") |
@POST, @PUT, @DELETE | @PostExchange, @PutExchange, @DeleteExchange |
@Path("id") | @PathVariable("id") |
@Query("page") | @RequestParam("page") |
@Header("X-Tenant") | @RequestHeader("X-Tenant") |
@Body | @RequestBody |
Call<User>, check isSuccessful() | User, or ResponseEntity<User>; errors throw |
The biggest behavioural difference is in the last rows. Retrofit's Call returns a Response for any status, and the caller checks isSuccessful(). Spring's client, backed by RestClient, throws HttpClientErrorException or HttpServerErrorException for 4xx and 5xx, unless we configure a status handler. A migration has to adjust every call site that relied on Retrofit's style.
2What Spring Integration Gives Us
Spring's interface clients run on RestClient or WebClient, so they inherit everything Spring Boot configures. The auto-configured RestClient.Builder registers Micrometer observation, so every call produces http.client.requests metrics tagged with method, URI template, status and outcome, and joins the distributed trace without extra code. Message converters are the same ones the rest of the service uses, so Jackson settings such as date formats apply everywhere. Errors use Spring's exception hierarchy, which our @ControllerAdvice and resilience tooling already understand. Timeouts and pools are configured through the same request factory settings as other clients, and in Spring Boot 4, through group properties for HTTP service clients (check your version).
With Retrofit, each of these needs explicit wiring: an OkHttp interceptor or event listener for metrics and tracing (Micrometer provides some for OkHttp; check your version), a configured ObjectMapper passed to the converter, and code to map Response errors to exceptions.
3What Retrofit Does Well
Retrofit and OkHttp are mature, widely used and well understood. OkHttp has excellent HTTP/2 support, connection pooling and interceptors. Retrofit has a large ecosystem of call adapters (RxJava, Kotlin coroutines, Guava, Java 8 CompletableFuture) and converters. And it runs on Android, which Spring's clients do not target. If the company has an SDK used both by Android apps and by backend services, Retrofit lets one client definition serve both.
4The Cost of Two HTTP Stacks
A Spring Boot service using Retrofit usually also has Spring clients somewhere, for example the auto-configured RestClient used by an actuator integration or a library. Two stacks mean two places to configure timeouts, two connection pools to size and monitor, two TLS setups for custom certificates, two ways of propagating trace headers, and two sets of metrics with different names. Each is small, but they add up across many services, and incidents are harder when one stack is configured and the other is forgotten. Removing Retrofit makes RestClient the only stack, configured once by the company starter.
5Estimating the Migration
For simple interfaces the migration is mechanical. Here is a Retrofit interface and its replacement.
Notice the call site changes too, because error handling changes. A practical approach is to configure a defaultStatusHandler that maps 404 to a domain exception and adjust callers in the same change, with tests against a stub server for 200, 404 and 500 to confirm behaviour. Interfaces using custom call adapters, streaming or OkHttp-specific interceptors take longer and should be estimated separately.
6Deciding
I would decide by two things. First, the platform standard: if the company starter configures RestClient with our timeouts, tracing and authentication, every Retrofit client is a client outside that safety net, and moving is part of staying on the paved road. Second, observability needs: if we need uniform metrics and traces across all outbound calls, Spring's built-in observation makes that the default instead of something every Retrofit client must remember.
So for a Spring Boot backend I would migrate gradually, one interface at a time, starting when code is touched. The exception is client code shared with Android or with non-Spring Java applications; there Retrofit remains the better fit, and we configure its OkHttpClient carefully to match the platform's timeouts and tracing.
- Is the client shared with Android or non-Spring code?YesKeep Retrofit, align its OkHttp configNoNext question
- Does the platform standard use RestClient?YesMigrate when touchedNoNext question
- Do we need uniform metrics and traces?YesMigrateNoKeep, but configure timeouts and metrics
3 steps in order. Play them, or step through them one at a time.
7Follow-up questions
Can Spring's interface clients use OkHttp underneath?
Spring offered an OkHttp-based request factory in the past, but it was deprecated in Spring Framework 6.1 and later removed, so check your version. Today the usual choices under RestClient are the JDK HttpClient, Apache HttpClient 5, Jetty or Reactor Netty.
Is there any feature Retrofit has that Spring's clients lack?
Retrofit's call adapter ecosystem is broader, and its Android support is unique. Spring's clients are more opinionated about error handling, which is usually an advantage in a Spring service but a difference to account for.
Would you migrate all clients at once?
No. Each interface is independent, so we can migrate them one at a time, each with its own tests and a metric comparison after deployment. Once the last one is gone, we remove the Retrofit and OkHttp dependencies.
8Conclusion
In this answer, we saw that Retrofit and Spring's HTTP interface clients share the same annotated-interface model, with annotations mapping almost one to one and error handling as the real difference. Spring's version integrates with Boot configuration, Micrometer observation, message converters and Spring's exceptions; Retrofit with OkHttp is mature, Android-friendly and rich in call adapters. Two HTTP stacks double the configuration of timeouts, pools, TLS and tracing, so we migrate a Spring Boot backend gradually when the platform standard and observability needs point to RestClient, and keep Retrofit where code is shared with Android.
Open with
Both are annotated interfaces, so the model is the same and the annotations map almost one to one: @GET becomes @GetExchange, @Path becomes @PathVariable, @Query becomes @RequestParam, @Body becomes @RequestBody.
Then, if they want more
The real behavioural difference is errors: Retrofit returns a Response you have to check with isSuccessful(), while Spring's client throws HttpClientErrorException or HttpServerErrorException, so call sites change too.
What Spring gives us is integration: the Boot RestClient.Builder already has Micrometer observation, so we get http.client.requests metrics and tracing for free, the same Jackson settings as the rest of the service, the same exception hierarchy, and timeouts configured like every other client. Retrofit is mature, OkHttp is excellent, it has lots of call adapters, and it runs on Android.
The thing I would weigh most is that a Spring service with Retrofit usually runs two HTTP stacks, so two places for timeouts, pools, TLS and trace propagation, and the one nobody remembers is where the incident happens.
So I would follow the platform standard: if the company starter is built on RestClient, I would migrate interfaces one at a time when we touch them, with stub-server tests for 200, 404 and 500. The exception is code shared with Android, where I would keep Retrofit and configure its OkHttp to match our standards.
About this answer
- Last updated
- 12 November 2026
- Versions it names
- Java 8, Spring Boot 4, Spring Framework 6
- 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 "A Spring Boot team uses Retrofit with OkHttp for all outbound calls. Should they move to...": https://scrivio-interview-library.netlify.app/spring-boot/http-clients/4373671fdc/