【SpringBoot学习笔记】运行错误:No fallback instance of type class found for feign client

【SpringBoot学习笔记】运行错误:No fallback instance of type class found for feign client,第1张

【SpringBoot学习笔记】运行错误:No fallback instance of type class found for feign client

[[报错情况:]]

feign中使用Hystrix,报错:No fallback instance of type class  found for feign client 

[源码:]

@FeignClient(value = "eureka-client", configuration = FeignConfig.class, fallback = HiHystrix.class)
public interface EurekaClientFeign {
    @GetMapping(value = "/hi")
    String sayHiFromClientEureka(@RequestParam(value = "name") String name);
}

@Component
public class HiHystrix implements EurekaClientFeign {
    @Override
    public String sayHiFromClientEureka(String name) {
        return "hi," + name + ",sorry,error!";
    }
}

[[原因和解决办法:]]
“HiHystrix”类实现“EurekaClientFeign”接口时,缺少注解“@Component”,导致编译时未将“HiHystrix”类自动实例化,当服务接口不

欢迎分享,转载请注明来源:内存溢出

原文地址: https://outofmemory.cn/zaji/5608970.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-12-15
下一篇 2022-12-15

发表评论

登录后才能评论

评论列表(0条)

保存