[springboot]Field newsMapper in com.news.service.NewsService required a bean of type 'com.news.

主要原因是bean没有注册上,
推荐方法:主程序 XXXApplication加上@MapperScan(“com.xxx.mapper”)。
其他方法:只要在对应POJP加上 @Component就好

主要错误:
Field newsMapper in com.news.service.NewsService required a bean of type ‘com.news.mapper.NewsMapper’ that could not be found.

  • @org.springframework.beans.factory.annotation.Autowired(required=true)
 java.lang.Object.wait(Native Method)
 java.lang.ref.ReferenceQueue.remove(ReferenceQueue.java:143)
 com.mysql.jdbc.AbandonedConnectionCleanupThread.run(AbandonedConnectionCleanupThread.java:43)
2020-01-20 14:23:25.528  INFO 10764 --- [  restartedMain] ConditionEvaluationReportLoggingListener : 

Error starting ApplicationContext. To display the conditions report re-run your application with 'debug' enabled.
2020-01-20 14:23:25.691 ERROR 10764 --- [  restartedMain] o.s.b.d.LoggingFailureAnalysisReporter   : 

***************************
APPLICATION FAILED TO START
***************************

Description:

Field newsMapper in com.news.service.NewsService required a bean of type 'com.news.mapper.NewsMapper' 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.news.mapper.NewsMapper' in your configuration.


Process finished with exit code 0

[springboot]Field newsMapper in com.news.service.NewsService required a bean of type 'com.news.[springboot]Field newsMapper in com.news.service.NewsService required a bean of type 'com.news. 时刻冷静 发布了5 篇原创文章 · 获赞 0 · 访问量 56 私信 关注
上一篇:news


下一篇:Python:爬取疫情每日数据