51,411
社区成员
发帖
与我相关
我的任务
分享依赖版本
<properties>
<java.version>8</java.version>
<spring-boot-version>2.6.11</spring-boot-version>
<spirng-cloud-version>2021.0.4</spirng-cloud-version>
<spring-cloud-alibaba-version>2021.0.4.0</spring-cloud-alibaba-version>
</properties>
feign客户端依赖
<!--OpenFeign声明式HTTP客户端-->
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-openfeign</artifactId>
</dependency>
<!--使用feign-httpclient依赖会导致feign原本的响应压缩失效-->
<dependency>
<groupId>io.github.openfeign</groupId>
<artifactId>feign-httpclient</artifactId>
</dependency>
Feign客户端配置
feign:
sentinel:
enabled: false
httpclient:
enabled: true
# 最大连接数
maxConnections: 200
# 每个路径的最大连接数
maxConnectionsPerRoute: 50
# 数据压缩
compression:
request:
enabled: true
min-request-size: 1
mime-types:
- image/png
- image/jpeg
- image/jpg
- text/html
- application/javascript
- text/css
- application/octet-stream
- application/json
- text/plain
response:
enabled: true
Feign服务端配置
server:
port: 8085
compression:
enabled: true
mime-types:
- image/png
- image/jpeg
- image/jpg
- text/html
- application/javascript
- text/css
- application/octet-stream
- application/json
- text/plain
min-response-size: 10B
移除“feign-httpclient”依赖后,响应压缩正常,如下图:

未移除 “feign-httpclient”依赖,响应压缩失效,如下图:

求大佬帮忙啊!!!
您好!从您的描述和配置中看,您已经正确地配置了Feign的压缩功能。但是,由于您使用了feign-httpclient依赖,可能存在一些与Apache HttpClient集成的问题。请尝试以下步骤解决问题:
更新依赖版本:检查是否有最新版本的feign-httpclient可用,并尝试将其升级到最新版本,以确保修复了可能存在的问题。
排除冲突的依赖:在您的feign-httpclient依赖中排除掉与Apache HttpClient相关的冲突依赖,以确保Feign与HttpClient的集成正确。
排查配置:确保feign.httpclient.enabled属性已正确设置为true。
检查压缩设置:检查Feign客户端和服务端的压缩配置是否匹配,并且确保MIME类型和最小响应大小设置正确。
如果以上步骤都不能解决问题,建议尝试使用其他HTTP客户端,如feign-okhttp,看看是否能够正常工作。