hystrix出現fallback method wasn`t found:xxx

com.netflix.hystrix.contrib.javanica.exception.FallbackDefinitionException: fallback method wasn't found: fallback

 

解決方法:

以下代碼就會出現這個錯誤:

@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 "系統正在維護中。。。";

     }

 

正確用法:http://www.yayihouse.com/yayishuwu/chapter/2649

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章