使用HTTP Feign替换Feign默认Client

mac2025-11-09  9

一 关键pom

<!-- Spring Cloud OpenFeign的Starter的依赖 --> <dependency> <groupId>org.springframework.cloud</groupId> <artifactId>spring-cloud-starter-openfeign</artifactId> </dependency> <!-- 使用Apache HttpClient替换Feign原生httpclient --> <dependency> <groupId>org.apache.httpcomponents</groupId> <artifactId>httpclient</artifactId> </dependency> <dependency> <groupId>com.netflix.feign</groupId> <artifactId>feign-httpclient</artifactId> <version>8.17.0</version> </dependency>

二 核心配置

server: port: 8010 spring: application: name: ch4-3-httpclient feign: httpclient: enabled: true

三 其他代码位置

https://github.com/cakin24/spring-cloud-code/tree/master/ch4-3/ch4-3-httpclient

四 运行测试

最新回复(0)