Sitemap
Javarevisited

A humble place to learn Java and Programming better.

Member-only story

Replace Feign With Spring Boot 4 HTTP Service Clients: @HttpExchange Step by Step

--

Spring Cloud OpenFeign has been feature-complete since 2022, and Spring Boot 4 now registers declarative HTTP clients itself, with base URLs and timeouts in properties. Here is every Feign feature mapped to its replacement, and the three that have none.

Press enter or click to view image in full size
Your code calls an interface, and Spring Boot 4 turns each call into HTTP, with the URL, timeouts and credentials set per group. The Feign and Spring Cloud stack it replaces is greyed out beside it.

Here is a Feign client of the kind that sits in most Spring microservices:

@FeignClient(name = "inventory", url = "${inventory.url}",
configuration = InventoryFeignConfig.class)
public interface InventoryClient {
@GetMapping("/stock/{sku}")
StockLevel stock(@PathVariable("sku") String sku);
@PostMapping("/reservations")
Reservation reserve(@RequestBody ReserveRequest request);
}

To make that interface work, the project pulls in spring-cloud-starter-openfeign, the Spring Cloud BOM, and a Spring Cloud release train that has to match your Spring Boot version. Every Boot upgrade waits for a compatible Spring Cloud release. And the library you are waiting for has been feature-complete since Spring Cloud 2022.0: it gets bug fixes, and the Spring team points new code at Spring's own HTTP Service Clients instead.

Spring Framework has had declarative HTTP interfaces since version 6. What changed in Spring Framework 7 and Spring Boot 4 is the part Feign was really…

--

--

Full stack Developer, Architect, Lead , Agile

See more from me

Javarevisited
Javarevisited

Published in Javarevisited

A humble place to learn Java and Programming better.