1、异常
2、分析异常内容,不难看出是,fallbackMethod配置的方法名错误
3、原因
fallbackMethod的方法签名和rest的方法不一致,导致的错误。
修改成一致即可。
@GetMapping("/get/{id}")
@HystrixCommand(fallbackMethod="getFallback")
public Dept get(@PathVariable("id") long id){
Dept dept = deptService.get(id);
if(dept == null){
throw new RuntimeException("部门信息不存在");
}
return dept;
}
//
public Dept getFallback(@PathVariable("id") long id){
Dept dept = new Dept();
dept.setDeptno(999999L);
dept.setDname("get method is error");
dept.setLoc("dept - provider ");
return dept;
}
重新访问,oK