com.netflix.hystrix.contrib.javanica.exception.FallbackDefinitionException: fallback method wasn't found: fallback
解决方法:
以下代码就会出现这个错误,因为fallback方法参数和sayHello参数数目和类型都不对应导致的:
@RequestMapping("/hello")
@ResponseBody
@HystrixCommand(fallbackMethod = "fallback")
public String sayHello(@RequestParam("txt") String txt) throws Exception {
if("0".equals(txt)){
throw new Exception();
}
return "收到你传过来的参数为:"+txt;
}
public String fallback(){
return "系统正在维护中。。。";
}
正确用法:
public String fallback( String txt){
return "系统正在维护中。。。";
}