zoukankan      html  css  js  c++  java
  • 关于 hystrix 的异常 fallback method wasn't found

    典型如下:

    @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;
    }

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

  • 相关阅读:
    程序的机器级表示(一)
    virtual memory(1)
    Python定义参数数量可变的method的问题
    存储器结构层次(四)
    CAShapeLayer
    cell
    远程服务器推送
    keyboad
    search搜索
    Cocoopod
  • 原文地址:https://www.cnblogs.com/wangjing666/p/7002955.html
Copyright © 2011-2022 走看看