SpringBoot
遇到的問題
遇到錯誤提示 required a bean of type 'com.xxx.xxx.dao.UserDao' that could not be found. 但是查看使用UserDao的UserController已經使用了@AutoWired,並且UserDao也加了@Repository註解。
required a bean of type 'com.xxx.xxx.dao.UserDao' that could not be found.
Action:Consider defining a bean of type 'com.xxx.xxx.dao.UserDao' in your configuration.
引起問題的原因
後來發現是因爲UserDao使用的UserEntity類沒有添加@Entity註解
解決辦法
對UserEntity類添加@Entity註解
Append
查看網絡資料發現引起這個錯誤的原因可能各不相同,還是得多查看熟悉自己的代碼,遇到這個錯誤很多是因爲改別人的項目時不熟悉代碼遇到的