Spring Cloud Feign报错’xx.FeignClientSpecification’, defined in null, could not be registered

错误描述

版本使用的是:

  • SpringBoot: 2.1.3.RELEASE
  • SpringCloud: Greenwich.SR1
  • OpenFeign: 2.1.0.M2

报错:

The bean 'xxxx.FeignClientSpecification', defined in null, could not be registered. 
A bean with that name has already been defined in null and overriding is disabled.

Caused by: org.springframework.beans.factory.support.BeanDefinitionOverrideException: 
Invalid bean definition with name xxxx.FeignClientSpecification' defined in null: 
Cannot register bean definition [Generic bean: class [org.springframework.cloud.openfeign.FeignClientSpecification]; scope=; abstract=false; lazyInit=false; autowireMode=0; dependencyCheck=0; autowireCandidate=true; primary=false; factoryBeanName=null; factoryMethodName=null; initMethodName=null; destroyMethodName=null] for bean 'xxxx.FeignClientSpecification': There is already [Generic bean: class [org.springframework.cloud.openfeign.FeignClientSpecification]; scope=; abstract=false; lazyInit=false; autowireMode=0; dependencyCheck=0; autowireCandidate=true; primary=false; factoryBeanName=null; factoryMethodName=null; initMethodName=null; destroyMethodName=null] bound.

解决方案

多个接口上的@FeignClient("相同服务名")会报错,A bean with that name has already been defined in null and overriding is disabled.

在application.yml中配置:

spring:
  main:
    allow-bean-definition-overriding: true
上一篇 Spring Cloud开发pom.xml踩坑记录
下一篇 Spring Boot使用@ConfigurationProperties加载配置文件
目录
文章列表
1 Retrofit2学习之八:服务端上传文件设计
Retrofit2学习之八:服务端上传文件设计
2
Java实现拼手气红包算法
Java实现拼手气红包算法
3
高中数学基础:二项分布与二项式定理
高中数学基础:二项分布与二项式定理
4
CSS设置select或option文本居中居右对齐
CSS设置select或option文本居中居右对齐
5
基于JWT的token身份认证方案
基于JWT的token身份认证方案
最新评论
一位WordPress评论者
一位WordPress评论者
2月12日
您好,这是一条评论。若需要审核、编辑或删除评论,请访问仪表盘的评论界面。评论者头像来自 Gravatar。