1、报错日志
org.springframework.beans.factory.support.BeanDefinitionOverrideException: Invalid bean definition with name 'weChatTransferFeignClient.FeignClientSpecification' defined in null: Cannot register bean definition [Generic bean: class [org.springframework.cloud.openfeign.FeignClientSpecification]; scope=; abstract=false; lazyInit=null; autowireMode=0; dependencyCheck=0; autowireCandidate=true; primary=false; factoryBeanName=null; factoryMethodName=null; initMethodName=null; destroyMethodName=null] for bean 'weChatTransferFeignClient.FeignClientSpecification': There is already [Generic bean: class [org.springframework.cloud.openfeign.FeignClientSpecification]; scope=; abstract=false; lazyInit=null; autowireMode=0; dependencyCheck=0; autowireCandidate=true; primary=false; factoryBeanName=null; factoryMethodName=null; initMethodName=null; destroyMethodName=null] bound.
2、原因分析
@FeignClient中,难么指向的服务有重复
3、解决方案
方案1
在配置文件添加
spring:
main:
allow-bean-definition-overriding: true
方案2
把feign放到同一个调用类之中
本文分析了一个关于Spring Cloud Feign的报错日志,指出在@FeignClient注解中指定了相同服务导致的冲突。提供了两种解决方案:1) 在配置文件中设置`spring.main.allow-bean-definition-overriding=true`允许覆盖;2) 将Feign客户端集中到一个调用类中。
652

被折叠的 条评论
为什么被折叠?



