工作生活

Feign

2019-06-29  本文已影响0人  a丶逍遥子

版本介绍

SpringBoot 版本 2.1.6.RELEASE
SpringCloud 版本 Greenwich.SR1

依赖包

        <dependency>
            <groupId>org.springframework.cloud</groupId>
            <artifactId>spring-cloud-starter-openfeign</artifactId>
        </dependency>
        <dependency>
            <groupId>io.github.openfeign</groupId>
            <artifactId>feign-okhttp</artifactId>
        </dependency>
    <!-- jar包版本管理 -->
    <dependencyManagement>
        <dependencies>
            <dependency>
                <groupId>org.springframework.cloud</groupId>
                <artifactId>spring-cloud-dependencies</artifactId>
                <version>${spring-cloud.version}</version>
                <type>pom</type>
                <scope>import</scope>
            </dependency>
        </dependencies>
    </dependencyManagement>

OkHttp生效配置

feign:
  httpclient:
    enabled: false
    # 单位毫秒:默认2000毫秒
    connection-timeout: 2000
    # 线程池大小
    max-connections: 200
  okhttp:
    enabled: true

源码分析核心类

# 负载均衡器客户端
org.springframework.cloud.openfeign.ribbon.LoadBalancerFeignClient
# Okhttp配置
org.springframework.cloud.openfeign.ribbon.OkHttpFeignLoadBalancedConfiguration
上一篇下一篇

猜你喜欢

热点阅读