1. 程式人生 > >spring註入時報錯::No qualifying bean of type 'xxx.xxMapper'

spring註入時報錯::No qualifying bean of type 'xxx.xxMapper'

and class can 解決 base ica fail pri exception

做一個小項目,因為有 baseService,所以偷懶就沒有寫單獨的每個xxService接口,直接寫的xxServiceImpl,結果在service實現類中註入Mapper的時候,用的 @Autowired,

結果,junit一啟動,就報錯誤:Java.lang.illegalStateException:Failed to load ApplicationContext

具體是在 創建bean的時候報:No qualifying bean of type ‘xxx.xxMapper‘ abailable:expected at least 1 bean which qualifies as autowire candidate.......

錯誤,

經過百度即測試,發現解決方法是:

在@Autowired 註解下面加上@Qualifier(“xxxxxMapper”)註解

spring註入時報錯::No qualifying bean of type 'xxx.xxMapper'