项目启动报错:Field XXX in required a bean of type ‘XXX‘ that could not be found

7 篇文章 1 订阅
Error starting ApplicationContext. To display the auto-configuration report re-run your application with 'debug' enabled.
2019-08-06 16:57:34.058 [ERROR] [main] [org.springframework.boot.diagnostics.LoggingFailureAnalysisReporter-] | 

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

Description:

Field bulletinContentMapper in com.bai.spcg.bulletin.distributer.server.cron.task.DefaultSendListener required a bean of type 'com.bai.spcg.bulletin.distributer.server.cron.task.mapper.BulletinContentMapper' that could not be found.


Action:

Consider defining a bean of type 'com.bai.spcg.bulletin.distributer.server.cron.task.mapper.BulletinContentMapper' in your configuration.


Process finished with exit code 1

解决:

配置mybatis,指定扫描的包。

方法1

        启动类加注解:@MapperScan(basePackages = { "mapper所在的包路径" }, sqlSessionFactoryRef = "sqlSessionFactory"),表示扫描com.bai.bulletin.distributer包下的所有mapper。 (只加@MapperScan(basePackages = { "com.bai.bulletin.distributer" }便解决了)

方法2

        直接在你生成出来的***Mapper.java类上加@Mapper标签。(这种方法试了,没有起作用)

参考:

https://86rev0.smartapps.cn/pages/blog/article-detail?userName=Julycaka&articleId=80622754

https://www.cnblogs.com/copykakaxi/p/11059427.html

@repository的含义,并且有时候却不用写,为什么?-CSDN博客

  • 1
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 3
    评论
评论 3
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值