Caused by: org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type 'com.beyondsoft.ruivision.common.api.platform.bandbinding.BandBindingFeignService' available: expected at least 1 bean which qualifies as autowire candidate. Dependency annotations: {@org.springframework.beans.factory.annotation.Qualifier(value=BandBindingFeignServiceImpl), @org.springframework.beans.factory.annotation.Autowired(required=true)}
原因:bean沒有注入!
1.包掃描路徑錯誤
<context:component-scan base-package="com.oliversun.app.service" />
2.接口的實現類忘記加 @Service 注解
3.還有一種可能 自動注入失敗!
我在寫Test測試類遇到過此問題,這里自動注入的Service實際上是FeginClient。
通過設置 @Autowired的required為false解決
關於required屬性: 附上站內大佬文章的傳送門