openfeign接口启动报错: is not assignable to interface feign.hystrix.FallbackFactory
openfeign接口启动报错: is not assignable to interface feign.hystrix.FallbackFactory
- 报错详情:
org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name ‘goodsController’: Unsatisfied dependency expressed through field ‘wareHouseOpenFienService’; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name ‘com.changgou.service.goods.service.openfien.WareHouseOpenFienService’: Unexpected exception during bean creation; nested exception is java.lang.IllegalStateException: Incompatible fallbackFactory instance. Fallback/fallbackFactory of type class com.changgou.service.goods.service.openfien.WareHouseOpenFienServiceFallbackFactory is not assignable to interface feign.hystrix.FallbackFactory for feign client wareHouseOpenFienService
从报错中可以看出: is not assignable to interface feign.hystrix.FallbackFactory 提示不能分配给接口false .hystrix. fallbackfactory
- 接口代码:
@FeignClient(name = "wareHouseOpenFienService",url = "http://127.0.0.1:9101/changgou-warehouse",fallbackFactory = WareHouseOpenFienServiceFallbackFactory.class)
public interface WareHouseOpenFienService {/*** 根据商品id集合查询库存信息* @param goodsIds* @return*/@PostMapping(value = "/queryListByGoodsIds")R<List<Warehouse>> queryListByGoodsIds(@RequestBody List<Long> goodsIds);
}
可以看到接口配置了fallbackFactory接口
- WareHouseOpenFienServiceFallbackFactory代码:
@Component
public class WareHouseOpenFienServiceFallbackFactory implements FallbackFactory<WareHouseOpenFienService> {@Overridepublic WareHouseOpenFienService create(Throwable cause) {return goodsIds -> R.fail("调用查询库存信息接口失败:" + cause);}
}
从代码上看没有任何问题, 报错原因是因为WareHouseOpenFienServiceFallbackFactory中实现的FallbackFactory接口需要注意, 是feign.hystrix.FallbackFactory而不是org.springframework.cloud.openfeign.FallbackFactory 所以导包时需要注意:
是: import feign.hystrix.FallbackFactory;
而不是: import org.springframework.cloud.openfeign.FallbackFactory;
openfeign接口启动报错: is not assignable to interface feign.hystrix.FallbackFactory相关推荐
- SpringBoot 启动报错 Specified class is an interface
springboot项目启动报错 Specified class is an interface 然后通过百度找到解决方案说项目中有重复命名的Mapper文件,修改文件名重启 但是按照解决方案重命名了 ...
- fagin 启动报错 Fallback/fallbackFactory
Fallback/fallbackFactory of type class is not assignable to interface feign.hystrix.FallbackFactory ...
- xcode高版本常见的RN本地启动报错
xcode编译报错:'config.h' file not found 解决方案 cd node_modules/react-native/third-party/glog-0.3.4 ../../s ...
- 调用后台接口返回报错前端隐藏提示_腾讯社交联盟广告
开发者帮助中心 优量汇服务体系升级了,除查阅本页常见问题外,还可以通过以下渠道解决您遇到的问题 1. 实时智能客服 入口:优量汇官网.开发者平台.优量汇服务号 时间:7*24即时问答 服务内容:涵盖 ...
- Spring项目启动报错No qualifying bean of type [xxx] available: expected single matching bean but found 2
启动报错: No qualifying bean of type [class1] available: expected single matching bean but found 2,class ...
- mysql启动失败LSB_mysql启动报错:Failed to start LSB: start and stop MySQL
报错信息: [root@youxx- bin]# service mysql status Redirecting to /bin/systemctl status mysql.service ¡ñ ...
- 【图文详解】SpringBoot项目启动报错:The bean ‘xxxServiceImpl‘ could not be injected as a ‘xxxServiceImpl‘ ...
问题描述: 项目启动报错:The bean 'xxxServiceImpl' could not be injected as a 'cn.xxxx.service.xxxServiceImpl' b ...
- Spring循环引用-@Async注解启动报错,而@Transactional则不会
目录 一.问题描述 二.问题分析 1.代理类 2.代理过程 三.结论 上接<Spring循环引用-@Async注解启动报错分析> 一.问题描述 Bean1Service注解@Async 启 ...
- 启动报错:Caused by: org.apache.ibatis.binding.BindingException汇总解决
报错 Springboot启动时从nacos拉取配置.启动报错: Caused by: org.apache.ibatis.binding.BindingException: Invalid boun ...
最新文章
- 用Kubernetes部署超级账本Fabric的区块链即服务(1)
- 你真的理解零拷贝吗?
- java.lang.RuntimeException: can not run elasticsearch as root
- 修改Linux的基本配置(如主机名、ip等)
- Exchange 2003 OWA登陆非常慢!
- 利用Android 8.0 ShortcutManager创建桌面快捷图标
- 【UVA - 10891 Game of Sum 】【HRBUST - 1622】 Alice and Bob (区间dp,博弈问题)
- 蒙山中学网站的服务器,上海金山区蒙山中学
- Target runtime com.genuitec.runtime.generic.jee60 is not defined
- Abseil之拆分字符串
- vue.js 调用iOS原生方法,JavaScriptCore
- express入门学习(一)
- linux mysql 数据恢复_怎样恢复Mysql数据库误删除后的数据
- iOS 图片裁剪功能。
- js通过base64编码显示图片
- 网络维护汇总经典问题集
- OSPF你懂多少之经典问题50个
- android中的单位——pt
- js中的定时器和计时器使用
- 解决insmod error inserting 'hello ko' -1 Invalid module form