zoukankan      html  css  js  c++  java
  • openfeign与gateway中的httpClient类声明冲突

    启动spring cloud中的网关,报错:

    ***************************
    APPLICATION FAILED TO START
    ***************************

    Description:

    The bean 'httpClient', defined in class path resource [org/springframework/cloud/openfeign/ribbon/HttpClientFeignLoadBalancedConfiguration$HttpClientFeignConfiguration.class], could not be registered. A bean with that name has already been defined in class path resource [org/springframework/cloud/gateway/config/GatewayAutoConfiguration$NettyConfiguration.class] and overriding is disabled.

    Action:

    Consider renaming one of the beans or enabling overriding by setting spring.main.allow-bean-definition-overriding=true

    我用的网关是gateway,内部调用是用的openfeign,这两者会冲突,上面报错信息显示httpClient在两者都有声明,要把两者中一者去掉,于是看了下两个类的源码,可以把feign上的httpClient禁用了。

    org/springframework/cloud/openfeign/ribbon/HttpClientFeignLoadBalancedConfiguration$HttpClientFeignConfiguration.class的代码中有如下图:


    上面可以看出,可以配置:

    feign.httpclient.enabled=false

    或者

    feign.compression.response.enabled=true

    来禁用openfeign的httpClient类定义

    也可以直接用配置:spring.main.allow-bean-definition-overriding=true 

    原文地址:http://www.classinstance.cn/detail/53.html
  • 相关阅读:
    agc027D
    agc027E
    agc036D
    牛客挑战赛43 D-数组操作
    CF587F. Duff is Mad
    CF578F. Mirror Box
    CF708D. Incorrect Flow
    agc022D
    2020.12.16 模拟赛x+1
    Mybatis Plus——[Could not set property 'id' of '***' with value]解决方案
  • 原文地址:https://www.cnblogs.com/jpfss/p/11906764.html
Copyright © 2011-2022 走看看