1. 程式人生 > 實用技巧 >Could not autowire. No beans of ‘xxxxx‘ type found.

Could not autowire. No beans of ‘xxxxx‘ type found.

標題名 不能自動裝配,沒有發現'xxxxx'型別的bean。

有幾種情況

很常見啊!今天浪費了我好幾分的時間來解決 記錄一下

第一種

我用的idea 有時候

@Autowired 去自動裝配會報紅線,看著就難受,但是在執行不會出問題的情況下呢,可以去調低它的檢測級別

調整為 Warning 就可以了

第二種 !!!! [我也是這個問題!]

確實報錯了,注入的時候為 null 報 NullPointerException 異常

這時候要檢查你注入的類是啥!

配置類,工具類等等,需要需要加上

@Component 註解 之後就OK了! 檢查一下吧!