关于hystrix.contrib.javanica.exception.FallbackDefinitionException: fallback method wasn't found异常
在Spring中使用断路器后可能会遇到:com.netflix.hystrix.contrib.javanica.exception.FallbackDefinitionException: fallback method wasn't found
典例如下:
@Service public class OrderService { @Autowired RestTemplate restTemplate; @HystrixCommand(fallbackMethod = "helloError") public String getOrder(Integer a, Integer b){ return restTemplate.getForObject("http://customer-business-service/show?a="+a+"&b="+b, String.class); } public String helloError(){ return "error"; } }
访问出现异常:
com.netflix.hystrix.contrib.javanica.exception.FallbackDefinitionException: fallback method wasn't found: helloError([class java.lang.Integer, class java.lang.Integer]) at com.netflix.hystrix.contrib.javanica.utils.MethodProvider$FallbackMethodFinder.doFind(MethodProvider.java:190) ~[hystrix-javanica-1.5.12.jar:1.5.12] at com.netflix.hystrix.contrib.javanica.utils.MethodProvider$FallbackMethodFinder.find(MethodProvider.java:159) ~[hystrix-javanica-1.5.12.jar:1.5.12] at com.netflix.hystrix.contrib.javanica.utils.MethodProvider.getFallbackMethod(MethodProvider.java:73) ~[hystrix-javanica-1.5.12.jar:1.5.12] at com.netflix.hystrix.contrib.javanica.utils.MethodProvider.getFallbackMethod(MethodProvider.java:59) ~[hystrix-javanica-1.5.12.jar:1.5.12] at com.netflix.hystrix.contrib.javanica.aop.aspectj.HystrixCommandAspect.setFallbackMethod(HystrixCommandAspect.java:342) ~[hystrix-javanica-1.5.12.jar:1.5.12] at com.netflix.hystrix.contrib.javanica.aop.aspectj.HystrixCommandAspect.access$300(HystrixCommandAspect.java:66) ~[hystrix-javanica-1.5.12.jar:1.5.12] at com.netflix.hystrix.contrib.javanica.aop.aspectj.HystrixCommandAspect$MetaHolderFactory.metaHolderBuilder(HystrixCommandAspect.java:187) ~[hystrix-javanica-1.5.12.jar:1.5.12] at com.netflix.hystrix.contrib.javanica.aop.aspectj.HystrixCommandAspect$CommandMetaHolderFactory.create(HystrixCommandAspect.java:269) ~[hystrix-javanica-1.5.12.jar:1.5.12] at com.netflix.hystrix.contrib.javanica.aop.aspectj.HystrixCommandAspect$MetaHolderFactory.create(HystrixCommandAspect.java:177) ~[hystrix-javanica-1.5.12.jar:1.5.12] at com.netflix.hystrix.contrib.javanica.aop.aspectj.HystrixCommandAspect.methodsAnnotatedWithHystrixCommand(HystrixCommandAspect.java:95) ~[hystrix-javanica-1.5.12.jar:1.5.12] at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:1.8.0_112] at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[na:1.8.0_112] at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[na:1.8.0_112] at java.lang.reflect.Method.invoke(Method.java:498) ~[na:1.8.0_112]
这是因为指定的 备用方法 和 原方法 的参数类型,个数不同造成的。需要统一参数列表,修改成:
@Autowired RestTemplate restTemplate; @HystrixCommand(fallbackMethod = "helloError") public String getOrder(Integer a, Integer b){ return restTemplate.getForObject("http://customer-business-service/show?a="+a+"&b="+b, String.class); } public String helloError(Integer a, Integer b){ return "error page. params:a="+a+", b="+b; }
这样就可以解决上述异常,正常访问了。
关于hystrix.contrib.javanica.exception.FallbackDefinitionException: fallback method wasn't found异常的更多相关文章
- com.netflix.hystrix.contrib.javanica.exception.FallbackDefinitionException: fallback method wasn't found: serviceError([class java.lang.String]) 异常
在使用spring cloud 的 Hystrix 后可能会遇到 如下截图错误: 后台代码如下: 找了好一会经过分析参数方法和原方法参数步一致造成: 修改后代码如下:
- 【spring cloud】子模块启动报错com.netflix.hystrix.contrib.javanica.aop.aspectj.HystrixCommandAspect
spring cloud子模块启动报错 Caused by: java.lang.ClassNotFoundException: com.netflix.hystrix.contrib.javanic ...
- 【spring cloud】spring cloud 使用feign调用,1.fallback熔断器不起作用,2.启动报错Caused by: java.lang.ClassNotFoundException: com.netflix.hystrix.contrib.javanica.aop.aspectj.Hystri解决
示例GitHub源码地址:https://github.com/AngelSXD/springcloud 1.首先使用feign调用,需要配置熔断器 2.配置熔断器需要将熔断器注入Bean,熔断器类上 ...
- springcloud报错-------关于 hystrix 的异常 FallbackDefinitionException:fallback method wasn't found
典型如下 第一种import java.util.List;@RestController@RequestMapping("/order")@DefaultProperties(d ...
- 解决 spring cloud 项目的 com.netflix.hystrix.contrib.javanica.aop.aspectj.HystrixCommandAspect 错误信息
在项目中引入:引入hystrix依赖,如下 <dependency> <groupId>org.springframework.cloud</groupId> &l ...
- java.lang.ClassNotFoundException: com.netflix.hystrix.contrib.javanica.aop.aspectj.HystrixCommandAspect
添加这个依赖 <dependency> <groupId>com.netflix.hystrix</groupId> <artifactId>hystr ...
- 使用hystrix监控时出现java.lang.ClassNotFoundException: com.netflix.hystrix.contrib.javanica.aop.aspectj.HystrixCommandAsp错误,导致无法启动
解决方法: 添加依赖 <dependency> <groupId>com.netflix.hystrix</groupId> <artifactId>h ...
- Spring Cloud 关于 hystrix 的异常 fallback method wasn't found
在 Spring Cloud 中使用断路器 hystrix 后,可能会遇到异常:com.netflix.hystrix.contrib.javanica.exception.FallbackDefin ...
- Hint: Fallback method 'public java.lang.String queryUserByIdFallback(java.lang.Long)' must return: User or its subclass
1.错误日志 熔断器添加错误方法返回时,报了一个 error. com.netflix.hystrix.contrib.javanica.exception.FallbackDefinitionExc ...
- 停止预览时调用Camera.release(), 出现Method called after release()异常问题原因及解决办法
如下代码: private void stopPreview() { Log.w(TAG, "stopPreview(), _isPreviewing = " + _isPrevi ...
随机推荐
- Mac下的终端高亮显示
默认安装之后Mac下的终端都是一色的黑白,所以需要做一番改造 推荐安装Linux使用的GNU Coreutils替换Mac的ls命令,因为: Coreutils提供了配置工具,定义颜色代码更加方便: ...
- 开源 - Ideal库 - Excel帮助类,TableHelper实现(二)
书接上回,我们今天开始实现对象集合与DataTable的相互转换. 01.接口设计 上文中已经详细讲解了整体设计思路以及大致设计了需要哪些方法.下面我们先针对上文设计思想确定对外提供的接口.具体接口如 ...
- Element Plus组件库el-select组件多选回显踩坑
前情 公司有经常需要做一些后台管理页面,我们选择了Element Plus,它是基于 Vue 3,面向设计师和开发者的组件库,是Vue框架生态中比较火的UI组件库,组件库丰富易用,组件链接:一个 Vu ...
- LocalLLaMA 客户端试验
LM Studio. 可以直接下 hg 模型(实际使用需要自己修改成中国镜像). 有 local server, 符合 openai api 规范. 遗憾的是不支持选择显卡导致无法使用. Farada ...
- 搭建 zerotier 的行星服务
放弃moon节点,直接搭建Zerotier根服务器_软件应用_什么值得买 Zerotier的优点在于其部署十分简便,只需在zerotier官网注册登陆并创建网络,在自己的设备安装客户端加入网络后,ze ...
- 夜莺 v8 第一个版本来了,开始做有意思的功能了
夜莺 v8 大版本已经启动开发,预计 25 年 7.8 月份发正式版,相比 v7 大概会做四五个大功能,每个功能做完了做稳定了都会提前放出来供大家体验,虽然以 beta 来命名,实际是稳定的,大家可以 ...
- .NET 在 Visual Studio 中的高效编程技巧集
前言 本文大姚将为你介绍一些Visual Studio的使用技巧和建议,旨在帮助.NET开发者更加高效地利用Visual Studio进行编程工作.无论你是.NET初学者还是经验丰富的.NET开发者, ...
- Qt开源作品22-运行时间记录类
一.前言 在早期开发的软件中,尤其是初学者入门者写的软件,软件运行久了,难免遇到意外崩溃的时候,可是大部分的运行设备可能在现场客户那,需要记住每一次从软件启动后到软件意外关闭前的运行时间,需要记录的信 ...
- SpringBoot集成swagger后出现: Failed to start bean ‘documentationPluginsBootstrapper‘的解决方法
SpringBoot集成swagger后出现: Failed to start bean 'documentationPluginsBootstrapper'的编译错误: org.springfram ...
- 在用Android StudioBuild项目时,提示:Could not resolve all files for configuration ':classpath'.Could not find com.android.tools.
在用Android StudioBuild项目时,提示:Could not resolve all files for configuration ':classpath'.Could not fin ...