Consider defining a bean of type 'xx.xx.dao.UserDao' in your configuration.
阿新 • • 發佈:2018-12-20
首先因為沒配資料來源的問題在Application啟動類上加了@SpringBootApplication(exclude = {DataSourceAutoConfiguration.class}),解決啟動報錯的問題,後來資料來源配好忘了去掉,所以後來變報了這個錯,花了不少時間找原因。 啟動報這個錯
ERROR 13304 --- [ main] o.s.b.d.LoggingFailureAnalysisReporter : *************************** APPLICATION FAILED TO START *************************** Description: Field userDao in cn.first.service.ServiceImp.UserServiceImp required a bean of type 'cn.first.dao.UserDao' that could not be found. Action: Consider defining a bean of type 'cn.first.dao.UserDao' in your configuration. Process finished with exit code 1
一開始以為注入有問題,但@Mapper註解也有,因為用的是idea所以注入時有警告 解決辦法在@Mapper下加@Component註解
最後把此前啟動類上的@SpringBootApplication(exclude = {DataSourceAutoConfiguration.class})改回@SpringBootApplication 啟動成功