Feign报错'xx.FeignClientSpecification', defined in null, could not be registered.

错误描述:
版本使用的是SpringBoot: 2.1.0.RELEASE,SpringCloud: Greenwich.M1,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(“相同服务名”)会报错,overriding is disabled。

在application.yml中配置:

spring:
  main:
    allow-bean-definition-overriding: true

  
--

  • 2
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
当使用Feign进行远程调用时,有时会遇到.lang.reflect.InvocationTargetException异常。这个异常是由Java的反射机制引起的,表示在调用方法时发生了异常。 java.lang.reflect.InvocationTargetException是一个包装异常,它将原始异常封装在内部。通常,我们需要查看InvocationTargetException的getCause()方法来获取实际的异常信息。 出现java.lang.reflect.InvocationTargetException异常的原因可能有很多,以下是一些常见的情况: 1. 远程服务不可用:如果远程服务没有启动或者无法访问,Feign调用就会失败,并抛出InvocationTargetException异常。 2. 请求参数错误:如果Feign调用的请求参数不正确,例如参数类型不匹配或者缺少必要的参数,远程服务可能会抛出异常,并导致InvocationTargetException异常。 3. 远程服务异常:如果远程服务在处理请求时发生了异常,它可能会将异常信息返回给Feign客户端,并导致InvocationTargetException异常。 为了解决这个问题,我们可以通过以下步骤来排查: 1. 检查远程服务是否正常运行,并确保可以正常访问。 2. 检查Feign调用的请求参数是否正确,并与远程服务的接口定义进行对比。 3. 查看InvocationTargetException的getCause()方法返回的异常信息,以确定实际的异常原因。 4. 根据具体的异常原因采取相应的措施,例如修复远程服务的bug或者调整Feign调用的参数。 希望以上信息对您有帮助!如果您还有其他问题,请随时提问。

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值