code

feignClient

@FeignClient(name = "loc", url = "localhost:7777"
//        , fallbackFactory = FegBackFac.class
//        , fallback = FegBack.class
)
public interface Feg {
    @GetMapping("/{chapter}/{section}")
    String getContent(@PathVariable("chapter") String chapter, @PathVariable("section") String section);
}

fallback class

@Component
class FegBack implements Feg {
    @Override
    public String getContent(String chapter, String section) {
        return "feign exception  fallback       "  + chapter + " " + section;
    }
}

other

no @EnableFeignClients annotation and application.properties is empty spring cloiud version is 2020.0.4

request and response

http://10.8.70.220:8080/ch0/ch0-03.html feign exception fallback ch0 ch0-03.html

Englist desc ( maybe not accuracy )

I define a feignclient but with no fallback attr In project package , I have a fallback class as a spring bean As result , the fallback class is valid

Chinese desc

我定义了 feignclient 但是并未执行它的 fallback 属性 在扫描包内 我定义了可以被 spring 扫描的 fallback 类 结果是 这个 fallback 类生效了

Comment From: Aiernory

I know this writen, fallback class was regarded as a service