openfeign和fastdfs启动报错

一、概述

一直以来,公司的文件上传、下载功能大部分都是使用fastdfs作为文件存储方式,少量使用了oss,本地存储以及其他一些类似oss的存储服务,但这些功能都是分散到每个系统里面单独维护,这种方式维护工作量大。于是乎准备将这些功能整合为一个文件供多个场景使用。主要使用openfeign作为微服务间的访问工具,fastdfs作为文件存储服务。代码写好后启动失败。

二、问题描述

1、系统使用的两个核心包

<dependency>
    <groupId>com.github.tobato</groupId>
    <artifactId>fastdfs-client</artifactId>
</dependency>
<dependency>
    <groupId>org.springframework.cloud</groupId>
    <artifactId>spring-cloud-starter-openfeign</artifactId>
</dependency>

启动报错内容:The bean 'connectionManager', defined in class path resource [org/springframework/cloud/openfeign/FeignAutoConfiguration$HttpClientFeignConfiguration.class], could not be registered. A bean with that name has already been defined in URL [jar:file:/D:/maven/ldyx/repository/com/github/tobato/fastdfs-client/1.26.6/fastdfs-client-1.26.6.jar!/com/github/tobato/fastdfs/domain/conn/ConnectionManager.class] and overriding is disabled.

Action:

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

2、大概意思是openfeign和tobato两个依赖包中的connectionManager这个bean名字冲突了,可尝试通过配置spring.main.allow-bean-definition-overriding=true解决。尝试后发现没用

三、解决方案

1、经过多方查找资料发现openfeign可以使用两种方式发起http接口调用分别是httpclient和okhttp,默认是httpclient,就是这个和tobato包冲突了。解决方案如下

2、yml文件中添加如下配置:

feign:
  httpclient:
    enabled: false
  okhttp:
    enabled: true

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值