本文共 1398 字,大约阅读时间需要 4 分钟。
@FeignClient(value = "nacos-discovery")public interface FeignService { }@FeignClient(name = "nacos-discovery", fallback = EchoServiceFallback.class, configuration = FeignConfiguration.class)public interface EchoService { }
这样由于名称相同,启动会报错
org.springframework.beans.factory.support.BeanDefinitionOverrideException: Invalid bean definition with name 'nacos-discovery.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 'nacos-discovery.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.
spring.main.allow-bean-definition-overriding=true
配置不同的contextId
@FeignClient(value = "nacos-discovery",contextId = "nacos-discovery-1")@FeignClient(name = "nacos-discovery", fallback = EchoServiceFallback.class, configuration = FeignConfiguration.class , contextId = "nacos-discovery-0")
转载地址:http://ykawb.baihongyu.com/