Spring Cloud替换Feign默认Client

使用HTTP Client替换Feign默认Client

依赖配置

<!-- 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>

核心配置

feign:
  httpclient:
    enabled: true

使用okhttp替换Feign默认Client

依赖配置

<dependencies>
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-web</artifactId>
    </dependency>
    <!-- Spring Cloud OpenFeign的Starter的依赖 -->
    <dependency>
        <groupId>org.springframework.cloud</groupId>
        <artifactId>spring-cloud-starter-openfeign</artifactId>
    </dependency>
    <dependency>
        <groupId>io.github.openfeign</groupId>
        <artifactId>feign-okhttp</artifactId>
    </dependency>
</dependencies>

核心配置

feign:
  httpclient:
    enabled: false
  okhttp:
    enabled: true
上一篇 RestTemplate中使用ParameterizedTypeReference参数化类型支持泛型
下一篇 Spring Boot四大组件
目录
文章列表
1 Android TimerTask定时任务卡顿
Android TimerTask定时任务卡顿
2
Android集成支付宝SDK支付
Android集成支付宝SDK支付
3
SpringBoot+Lucene第四篇 — 入门代码
SpringBoot+Lucene第四篇 — 入门代码
4
微信支付WeixinJSBridge
微信支付WeixinJSBridge
5
Android获取SHA1证书指纹
Android获取SHA1证书指纹
最新评论
一位WordPress评论者
一位WordPress评论者
2月12日
您好,这是一条评论。若需要审核、编辑或删除评论,请访问仪表盘的评论界面。评论者头像来自 Gravatar。