1. 程式人生 > >使用 @Resource或@Autowire時 Idea報錯Could not autowire. No beans of 'xxxService' type found. more..出現紅色波浪線

使用 @Resource或@Autowire時 Idea報錯Could not autowire. No beans of 'xxxService' type found. more..出現紅色波浪線

錯誤: 

使用註解@Resource或者@Autowire intellij Idea報錯Could not autowire. No beans of 'xxxService' type found. more... (Ctrl+F1)

出現紅色波浪線

原因:

目前我遇到兩種情況:

1、編譯報錯時是因為xxxService的ServiceImpl實現類沒有加入註解@Service。

2、IntellijIDEA本身工具的問題。

解決方法:

1、在ServiceImpl實現類加入註解@Service

2、降低IDEA的Autowired檢測的級別。

在settings - Editor - Inspections - Spring - Spring Core - Code - Autowiring for Bean Class 勾去掉