Feign Hystrix后备不起作用

时间:2017-09-26 13:55:15

标签: java spring-boot hystrix netflix-feign spring-cloud-feign

我有下面的FeignClient:

@FeignClient(name="FooMS",fallback=CustomerFeign.CustomerFeignImpl.class)
public interface CustomerFeign {

    @RequestMapping(value="/bar/{phoneNo}")
    List<Long> getFriends(@PathVariable("phoneNo") Long phoneNo);


    class CustomerFeignImpl implements CustomerFeign{

        @Override
        public List<Long> getFriends(Long phoneNo) {
            return new ArrayList<Long>(108);
        }

    }

}

当FooMS实例关闭时,我得到500错误而不是正在执行的回退。为什么会这样?

2 个答案:

答案 0 :(得分:2)

将您的CustomerFeignImpl标记为@Component或从中创建@Bean

答案 1 :(得分:0)

添加@Component和feign.hystrix.enabled = true很好