fegin服务启动失败,容器中找不到接口类的bean,无法注入

今天初学fegin,运行fegin这个项目时提示无法找到service。

Description:
 
Field productClient in com.yore.order.service.impl.OrderServiceImpl required a bean of type 'com.yore.product.client.ProductClient' that could not be found.

解决:

出现这个问题,首先要确定在启动类上是否添加了@EnableFeignClients注解,并且需要配置上Feign客户端接口的包basePackages = "com.yore.product.client",

@EnableFeignClients(basePackages = "com.yore.product.client")

然后确定这两个服务引用的Spring Cloud和Spring Boot版本是否一致,有时因为不一致,在 第一个服务中注解可能引用的是org.springframework.cloud.netflix.feign.FeignClient这个包下的,另一个服务中引用的是org.springframework.cloud.openfeign.FeignClient包下的,这时也会包这个错误,

参考链接:https://blog.csdn.net/github_39577257/article/details/81842234

感谢该作者!

原文地址:https://www.cnblogs.com/yrtx/p/13167924.html