今天初學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
感謝該作者!