典型如下:

@HystrixCommand(fallbackMethod = "fallbackHi")
public String getHi(String x) {
String msg = restTemplate.getForObject("http://jack/hi", String.class);
return msg;
} public String fallbackHi(){
return "can't say hi";
}

这样就会出现如上所述的异常,这是因为指定的 备用方法 和 原方法 的参数个数,类型不同造成的;

所以需要统一参数的个数,类型:

@HystrixCommand(fallbackMethod = "fallbackHi")
public String getHi(String x) {
String msg = restTemplate.getForObject("http://jack/hi", String.class);
return msg;
} public String fallbackHi(String x){
return "can't say hi, and get: " + x;
}

这样就可以解决上述的异常了。

关于 hystrix 的异常 fallback method wasn't found的更多相关文章

  1. Spring Cloud 关于 hystrix 的异常 fallback method wasn't found

    在 Spring Cloud 中使用断路器 hystrix 后,可能会遇到异常:com.netflix.hystrix.contrib.javanica.exception.FallbackDefin ...

  2. 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 ...

  3. com.netflix.hystrix.contrib.javanica.exception.FallbackDefinitionException: fallback method wasn't found: serviceError([class java.lang.String]) 异常

    在使用spring cloud 的 Hystrix 后可能会遇到 如下截图错误: 后台代码如下: 找了好一会经过分析参数方法和原方法参数步一致造成: 修改后代码如下:

  4. springcloud报错-------关于 hystrix 的异常 FallbackDefinitionException:fallback method wasn't found

    典型如下 第一种import java.util.List;@RestController@RequestMapping("/order")@DefaultProperties(d ...

  5. Spring Boot中使用Feign调用时Hystrix提示异常:"could not be queued for execution and no fallback available."以及"Rejected command because thread-pool queueSize is at rejection threshold"

    说明: 1.我还没有真正理解Spring Cloud的精髓,现只停留在使用阶段,可能存在分析不到位的问题. 1.这个是由于线程池的最大数量导致的,官方说随着线程池的数量越大,资源开销也就越大,所以调整 ...

  6. Hystrix【异常机制处理】

    在之前的老版本中,feign中是默认开启hystrix的,从新版本中默认已经关闭了,如果要通过FeignClient调用服务并开启hystrix的话,需要自定义开启,即:feign.hystrix.e ...

  7. java-collections.sort异常Comparison method violates its general contract!

    转载:http://www.tuicool.com/articles/MZreyuv 异常信息 java.lang.IllegalArgumentException: Comparison metho ...

  8. hystrix(4) 异常降级

    当执行HystrixCommand时,如果发生命令执行异常.熔断器熔断.信号量超过数量,就会执行降级fallback方法,并返回结果.本质上,当出现以上情况是,执行fallback方法,而不是run方 ...

  9. SpringCloud系列-整合Hystrix的两种方式

    Hystrix [hɪst'rɪks],中文含义是豪猪,因其背上长满棘刺,从而拥有了自我保护的能力.本文所说的Hystrix是Netflix开源的一款容错框架,同样具有自我保护能力. 本文目录 一.H ...

随机推荐

  1. 百度地图API的第一次接触——自定义控件

    1.定义一个控件类,即function function ZoomControl(){ // 设置默认停靠位置和偏移量 this.defaultAnchor = BMAP_ANCHOR_TOP_LEF ...

  2. WPF ListView VisualPanel

                     <ItemsPanelTemplate x:Key="ItemsPanelTemplate1">                 &l ...

  3. shell expr 的使用注意事项

    #!/bin/bash a=10 b=20 c=`expr $a + $b` echo "a + b :$c" c='expr $a + $b' echo "a + b ...

  4. MySQL 之 导出导入数据

    导出数据库(sql脚本)  mysqldump -u 用户名 -p 数据库名 > 导出的文件名mysqldump -u root -p --databases db_name > test ...

  5. CodeForces 484B Maximum Value (数学,其实我也不知道咋分类)

    B. Maximum Value time limit per test 1 second memory limit per test 256 megabytes input standard inp ...

  6. minihttp安装配置ssl和c语言实现cgi

    概述:参考了大牛们的方法,结合自己的环境做了修改,主要是讲:minihttp安装配置ssl和c语言实现cgi接收字符串并且保存系统环境:centos6.5 开发版 依赖软件包: mini_httpd- ...

  7. JAVA学习笔记——(五)

    今日内容介绍 1.方法基础知识 2.方法高级内容 3.方法案例 01方法的概述 * A: 为什么要有方法 * 提高代码的复用性 * B: 什么是方法 * 完成特定功能的代码块. 02方法的定义格式 * ...

  8. Js获取当前的日期和时间以及时间戳转化为时间

    /** *获取当前时间 *format=1精确到天 *format=2精确到分 */ function getCurrentDate(format) { var now = new Date(); v ...

  9. php 连接 memcached 并调用

    话不多说,上代码,自己看注释 <?php header("Content-type: text/html; charset=utf-8"); $mem = new Memca ...

  10. Unity surface shader 2

    UV滚动 Shader "Nafio/ScrollUV" { Properties { _Tex("T",2D) = "white" {} ...