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
  • 相关阅读:
    Linux的web服务的介绍
    Linux的DNS主从服务器部署
    K8S Calico
    K8S flannel
    K8S dashboard
    K8S RBAC
    kubernetes认证和serviceaccount
    K8S 部署 ingress-nginx (三) 启用 https
    K8S 部署 ingress-nginx (二) 部署后端为 tomcat
    K8S 部署 ingress-nginx (一) 原理及搭建
  • 原文地址:https://www.cnblogs.com/jpfss/p/11906764.html
Copyright © 2011-2022 走看看