expected at least 1 bean which qualifies as autowire candidate for this dependency.


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屬性: 附上站內大佬文章的傳送門


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM