com.netflix.hystrix.contrib.javanica.exception.FallbackDefinitionException: Incompatible return types.
解决方法:
以下代码就会报这个错,因为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 Map fallback(String txt){
Map<String, String> map = new HashMap<>();
return map;
}