Feign

作者: a丶逍遥子 | 来源:发表于2019-06-29 19:13 被阅读0次

    版本介绍

    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
    

    相关文章

      网友评论

        本文标题:Feign

        本文链接:https://www.haomeiwen.com/subject/ystmcctx.html