码迷,mamicode.com
首页 > 其他好文 > 详细

fein---消费者启动报错问题

时间:2019-08-27 16:58:02      阅读:120      评论:0      收藏:0      [点我收藏+]

标签:object   mamicode   cpe   回调   RoCE   int   ebe   trade   cep   

Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name ‘com.bwton.tradecenter.tdbd.api.om.interfaces.BizOrderAccpetAPI‘: FactoryBean threw exception on object creation; nested exception is java.lang.IllegalStateException: Incompatible fallback instance. Fallback/fallbackFactory of type class com.bwton.tradecenter.tdbd.api.om.interfaces.TdbdOrderFallbackFactory is not assignable to interface com.bwton.tradecenter.tdbd.api.om.interfaces.BizOrderAccpetAPI for feign client tdbd-om-service
    at org.springframework.beans.factory.support.FactoryBeanRegistrySupport.doGetObjectFromFactoryBean(FactoryBeanRegistrySupport.java:185)
    at org.springframework.beans.factory.support.FactoryBeanRegistrySupport.getObjectFromFactoryBean(FactoryBeanRegistrySupport.java:103)
    at org.springframework.beans.factory.support.AbstractBeanFactory.getObjectForBeanInstance(AbstractBeanFactory.java:1640)
    at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:254)
    at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:202)
    at org.springframework.beans.factory.config.DependencyDescriptor.resolveCandidate(DependencyDescriptor.java:208)
    at org.springframework.beans.factory.support.DefaultListableBeanFactory.addCandidateEntry(DefaultListableBeanFactory.java:1316)
    at org.springframework.beans.factory.support.DefaultListableBeanFactory.findAutowireCandidates(DefaultListableBeanFactory.java:1282)
    at org.springframework.beans.factory.support.DefaultListableBeanFactory.doResolveDependency(DefaultListableBeanFactory.java:1101)
    at org.springframework.beans.factory.support.DefaultListableBeanFactory.resolveDependency(DefaultListableBeanFactory.java:1066)
    at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredFieldElement.inject(AutowiredAnnotationBeanPostProcessor.java:585)
    ... 32 common frames omitted
Caused by: java.lang.IllegalStateException: Incompatible fallback instance. Fallback/fallbackFactory of type class com.bwton.tradecenter.tdbd.api.om.interfaces.TdbdOrderFallbackFactory is not assignable to interface com.bwton.tradecenter.tdbd.api.om.interfaces.BizOrderAccpetAPI for feign client tdbd-om-service
    at org.springframework.cloud.netflix.feign.HystrixTargeter.getFromContext(HystrixTargeter.java:100)
    at org.springframework.cloud.netflix.feign.HystrixTargeter.targetWithFallback(HystrixTargeter.java:85)
    at org.springframework.cloud.netflix.feign.HystrixTargeter.target(HystrixTargeter.java:49)
    at org.springframework.cloud.netflix.feign.FeignClientFactoryBean.loadBalance(FeignClientFactoryBean.java:145)
    at org.springframework.cloud.netflix.feign.FeignClientFactoryBean.getObject(FeignClientFactoryBean.java:166)
    at org.springframework.beans.factory.support.FactoryBeanRegistrySupport.doGetObjectFromFactoryBean(FactoryBeanRegistrySupport.java:178)
    ... 42 common frames omitted

今天使用feign时 遇到一个问题  消费者启动一直报bean找不到

网上找了一下,大部分都说启动类@SpringBootApplication没有扫描到接口类所在包,但是我按照上面说的依旧没成功。

直到后来发现我的问题错在哪里

错误展示:

接口:

技术图片

回调:

技术图片

错误原因:

fallback类型时 对应回调应该是实现BizOrderAccpetAPI接口 ,重写方法

fallbackFactory类型时 对应回调应该是实现FallbackFactory<BizOrderAccpetAPI>接口,重写方法

 

正确配置:

第一种方式:fallback

 接口:

技术图片

回调:

技术图片

 

第二种方式:fallbackFactory

接口:

技术图片

回调:

技术图片

 

特此记录

 

fein---消费者启动报错问题

标签:object   mamicode   cpe   回调   RoCE   int   ebe   trade   cep   

原文地址:https://www.cnblogs.com/lxk233/p/11419295.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!