• 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
  • 相关阅读:
    英语老师不想让你知道的一些网站分享
    最近三周开发的桌面应用系统
    UML技术沙龙PPT
    Pandas时间处理的一些小方法
    合并函数总结
    开博宣言
    DBGrid中增加一列CHECKBOX
    关于Delphi的Hint
    操作EXCEL
    关于FastReport
  • 原文地址:https://www.cnblogs.com/jpfss/p/11906764.html
Copyright © 2020-2023  润新知