Why Spring 7 Is Moving Away From Feign (And What to Use Instead)
Spring 7 doesn’t remove Feign from the classpath but officially discourages its use, labeling OpenFeign as feature‑complete and recommending the new Spring Framework HTTP Service Client, with a detailed comparison, migration steps, and guidance on when Feign may still be viable.
Conclusion: Not Deprecated Yet, But No Longer Recommended
Spring 7 does not delete Feign from the classpath, so existing projects can still run, but the Spring team has declared OpenFeign feature‑complete —only bug fixes will be added and new features are no longer planned. The official recommendation is to migrate to the HTTP Service Client built into Spring Framework.
What Problem Did Feign Solve?
Feign’s core idea is to write remote HTTP calls as Java interfaces. Before Feign, a typical RestTemplate call looks like:
// Traditional RestTemplate usage – verbose and scattered
RestTemplate restTemplate = new RestTemplate();
String url = "http://user-service/users/" + userId;
User user = restTemplate.getForObject(url, User.class);With Feign, the same call becomes declarative:
@FeignClient(name = "user-service", path = "/users")
public interface UserClient {
@GetMapping("/{id}")
User getUser(@PathVariable("id") Long id);
}
@Service
public class OrderService {
private final UserClient userClient;
public OrderService(UserClient userClient) { this.userClient = userClient; }
public Order createOrder(Long userId) {
User user = userClient.getUser(userId); // looks like a local call
// ...
}
}Combined with Spring Cloud’s load‑balancing and circuit‑breaker integrations, Feign saved a lot of boiler‑plate in micro‑service projects.
Why Spring Is Shifting to HTTP Service Client
Spring 7 reorganises HTTP client support in three key ways:
RestTemplate is deprecated – the framework now recommends RestClient.
Declarative HTTP calls are moved into Spring Framework itself – no longer dependent on the external OpenFeign project.
New annotation @ImportHttpServices dramatically reduces the boiler‑plate needed to register client proxies.
Real‑World Pain Points of Feign in New Versions
1. Maintenance Mode – No New Features
Feature‑complete since 2022.0.0, so new Spring 7 capabilities are adopted slowly.
Upstream Feign features may not be integrated into Spring Cloud.
Documentation and examples are gradually shifting toward HTTP Service Client.
2. Longer Dependency Chain, Higher Upgrade Cost
Using Feign typically requires adding the spring-cloud-starter-openfeign starter, adding an extra layer of integration. The HTTP Service Client is part of Spring Framework / Spring Boot, so version alignment is simpler.
3. Inconsistent Annotation Model
Feign relies on @FeignClient and Spring MVC annotations ( @GetMapping, etc.), resulting in separate definitions for client interfaces and server controllers. The HTTP Service Client uses @HttpExchange annotations, allowing the same interface to be shared between client and server.
4. Mismatch with RestClient / WebClient Ecosystem
Feign implements its own call chain, whereas the native Spring solution builds on RestClient (synchronous) or WebClient (reactive), sharing the same underlying infrastructure.
Spring 7 Recommended Approach: HTTP Service Client
Step 1 – Define an HTTP Service Interface
/**
* User service HTTP client interface using Spring’s native @HttpExchange
*/
@HttpExchange("/users")
public interface UserHttpService {
@GetExchange("/{id}")
User getUser(@PathVariable Long id);
@PostExchange
User createUser(@RequestBody User user);
}Step 2 – Auto‑Register with @ImportHttpServices
@Configuration
@ImportHttpServices(group = "user-service", types = UserHttpService.class)
public class HttpClientConfig {
@Bean
RestClientHttpServiceGroupConfigurer userServiceConfigurer() {
return groups -> groups
.filterByName("user-service")
.forEachClient((_, builder) -> builder
.baseUrl("http://user-service")
.defaultHeader("Accept", "application/json"));
}
}Step 3 – Inject and Use in Business Code
@Service
public class OrderService {
private final UserHttpService userHttpService;
public OrderService(UserHttpService userHttpService) { this.userHttpService = userHttpService; }
public Order createOrder(Long userId) {
User user = userHttpService.getUser(userId);
// further business logic …
return new Order(user);
}
}For reactive calls, set clientType = WEB_CLIENT on @ImportHttpServices, allowing the same interface to work synchronously or asynchronously.
How Much Effort Is Needed to Migrate?
The migration is straightforward: replace @FeignClient with @HttpExchange, swap @EnableFeignClients for @ImportHttpServices, and adjust the underlying client configuration. The table below summarises the differences:
Declaration : @FeignClient → @HttpExchange Registration : @EnableFeignClients → @ImportHttpServices Underlying client : Feign’s own implementation → RestClient / WebClient Maintenance status : feature‑complete → continuously evolving
Dependency : external spring-cloud-openfeign → built‑in Spring Framework
When Is It Still Reasonable to Keep Using Feign?
Legacy projects that are stable on Spring Boot 2.x/3.x and lack migration budget.
Teams with extensive custom Feign extensions (custom decoders, interceptors, contract tests) where the short‑term switch cost is high.
Third‑party frameworks that are tightly bound to Feign.
However, for new Spring 7 / Spring Boot 4 projects or major version upgrades, there is no justification to stay with Feign—using the HTTP Service Client reduces future maintenance overhead.
Signed-in readers can open the original source through BestHub's protected redirect.
This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactand we will review it promptly.
java1234
Former senior programmer at a Fortune Global 500 company, dedicated to sharing Java expertise. Visit Feng's site: Java Knowledge Sharing, www.java1234.com
How this landed with the community
Was this worth your time?
0 Comments
Thoughtful readers leave field notes, pushback, and hard-won operational detail here.
