博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
@FeignClient注解的重复名称解决
阅读量:2155 次
发布时间:2019-05-01

本文共 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.

 

 

解决

方法1

spring.main.allow-bean-definition-overriding=true

 

方法2

配置不同的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/

你可能感兴趣的文章
PHPstudy中遇到的坑No input file specified,以及传到linux环境下遇到的坑,模板文件不存在
查看>>
TP5.1事务操作和TP5事务回滚操作多表
查看>>
composer install或composer update 或 composer require phpoffice/phpexcel 失败解决办法
查看>>
TP5.1项目从windows的Apache服务迁移到linux的Nginx服务需要注意几点。
查看>>
win10安装软件 打开时报错 找不到 msvcp120.dll
查看>>
PHPunit+Xdebug代码覆盖率以及遇到的问题汇总
查看>>
PHPUnit安装及使用
查看>>
PHP项目用xhprof性能分析(安装及应用实例)
查看>>
composer安装YII
查看>>
Sublime text3快捷键演示
查看>>
sublime text3 快捷键修改
查看>>
关于PHP几点建议
查看>>
硬盘的接口、协议
查看>>
VLAN与子网划分区别
查看>>
Cisco Packet Tracer教程
查看>>
02. 交换机的基本配置和管理
查看>>
03. 交换机的Telnet远程登陆配置
查看>>
微信小程序-调用-腾讯视频-解决方案
查看>>
phpStudy安装yaf扩展
查看>>
密码 加密 加盐 常用操作记录
查看>>