Description:
Field districtService in com.ymzh.controller.admin.MovieHandler required a bean of type 'com.ymzh.service.DistrictService' that could not be found.
The injection point has the following annotations:
- @org.springframework.beans.factory.annotation.Autowired(required=true)
Action:Consider defining a bean of type 'com.ymzh.service.DistrictService' in your configuration.
這是我這兩天第二次遇到這個問題了,今天特別來做下記錄。
看到一篇博客感覺寫的很好,在這裏貼一下。
關於spring boot自動注入出現Consider defining a bean of type 'xxx' in your configuration問題解決方案:https://blog.csdn.net/a532672728/article/details/77702772/
那麼我這次犯錯的原因,竟然是:把implements Service 寫成了 implements Dao的接口。
出現這個問題,一般先去檢查以下幾個點吧。
1、Service接口是否被實現了(我只是手誤了5555),
2、實現類是否加了Service註解,或者Component註解。
3、controller中是否加了@Autowired註解。
這些都沒有問題的話,那再去看看那篇博客吧,也許否能夠有所幫助。