很多场景下,需要了解回退的原因,此时可使用注解@FeignClient的fallbackFactory属性,下面通过一个例子说明
一 新建项目microservice-consumer-movie-feign-hystrix-fallback-factory
二 UserFeignClient如下
package com.itmuch.cloud.study.user.feign;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.cloud.netflix.feign.FeignClient;
import org.springframework.stereotype.Component;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import com.itmuch.cloud.study.user.entity.User;
import feign.hystrix.FallbackFactory;
@FeignClient(name = "microservice-provider-user", fallbackFactory = FeignClientFallbackFactory.class)
public interface UserFeignClient {
@RequestMapping(value = "/{id}", method

最低0.47元/天 解锁文章

被折叠的 条评论
为什么被折叠?



