今天在搭建微服务项目的时候遇到了一个问题

项目结构

实际的场景是OperationLogService需要注入OperationLogMapper,也就是最常见的业务层依赖数据层,但是项目启动的时候报了这个错误,最开始我还以为是Mapper没有注册到Spring中,检查了之后我确定Service和Mapper是没有问题的,然后找了好久也没有找到原因,这时候我想到会不会是Mapper没有被扫描到?于是我检查了一下Applicaiton启动类的位置,发现真的是这个问题

我各个模块的包命名规则是priv.cwr.log.模块名,我的Application启动类是放在priv.cwr.log.web下,由于Application启动类只会扫描自己所在的包及其子包下面,所以扫包的范围是priv.cwr.log.web同级包以及子包下,所以自然也就扫不到priv.cwr.log.mapper了, 把启动类放到priv.cwr.log目录下就解决了这个问题。

总结:建议下次遇到类似的问题,首先检查是不是类本身的问题,确定是否注册到了spring,比如是否有@Compoent注解之类的,如果确保了类没有问题,就去检查一下是否有被扫描到

Parameter 0 of constructor in XXX required a bean of type ‘XXX‘ that could not be found.相关推荐

  1. Parameter 1 of constructor in xxx required a bean of type xxx‘ that could not be found.已经解决

    使用Mybatis Plus 时遇到问题Parameter 1 of constructor in xxx required a bean of type xxx' that could not be ...

  2. springCloud Feign调用报错 Parameter 6 of constructor in xxxxxxxx required a bean of type ‘xxxxxx‘ that

    Description: Parameter 6 of constructor in xxxxxxx required a bean of type 'xxxxxxx' that could not ...

  3. springboot使用junit单元测试是发生报错 Field taskUtils in com.xxx.xxx.xxxx.xxx required a bean of type 'xxx.xxx.

    使用junit单元测试mybatis时发生如下错误 Error starting ApplicationContext. To display the conditions report re-run ...

  4. springboot踩坑日记——Field xxx.xxx.xxx required a bean of type 'xxx.xxx.xxx' that could not be found

    使用feign时报创建的feign接口找不到 Field xxx.xxx.xxx required a bean of type 'xxx.xxx.xxx' that could not be fou ...

  5. 使用Feign服务远程调用项目启动时报错:Field xxx in xxx required a bean of type xxx that could not be found.

    报错: *************************** APPLICATION FAILED TO START ***************************Description:F ...

  6. 解决:Parameter 0 of constructor in xxx required a bean of type ‘xxx‘ that could not be found.

    运行报错: Parameter 0 of constructor in com.xxx.Crawler required a bean of type 'java.lang.String' that ...

  7. 解决:Parameter 0 of constructor in XXX required a bean of type ‘XXX‘ that could not be found

    解决:Parameter 0 of constructor in com.mise.smart.entity.HrmNoticeEntity required a bean of type 'java ...

  8. spring boot报错:Parameter 4 of constructor in xx required a bean of type ‘xx‘ that could not be found.

    spring boot 项目启动服务时,报错: 根据报错提示,一直认为是 SpringBootApplication 没有扫描到对应的 bean 路径. 最后,仔细排查发现是粗心的问题,自定义的常量没 ...

  9. 【踩坑专栏】Field xxFeignClient in xxx required a bean of type ‘xxx.XXFeignClient‘ that could not be found

    首先我的feignClient上已标注解@FeignClient,出现这个问题的原因是因为启动类需要注解@EnableFeignClients(basePackages = "xx.xx.x ...

最新文章

  1. SAP QM IDI Interface
  2. 【Visual Studio 扩展工具】使用ComponentOne中的GroupDefinition和SortDefinition属性保存和还原布局...
  3. 研发工作中芯片选型需要考虑的问题
  4. jzoj4231-寻找神格【线段树,数学】
  5. Python爬虫自学之第(①)篇——爬虫伪装和反“反爬”
  6. 引用数据类型的方法调用
  7. 这个顶级AI赛事总奖池100W+!CV 、NLP赛题等你来战!
  8. VisualGDB系列10:快速调试Linux应用程序
  9. 第三天 LINUX安全
  10. php连接oracle设定字符集,避免乱码
  11. android实现标题栏弹框,Android:Dialog对话框、Builder、showDialog、模板方法设计模式...
  12. Could not connect to any servers in your MongoDB Atlas cluster. One common reason is that you‘re try
  13. FastReport 2021版中文手册PDF下载
  14. 爬虫学习——初步了解爬虫
  15. C++移动输出端的光标代码实现
  16. 在线教育投融数据(2015-2020年)
  17. 开发人员选择驻场有什么好处
  18. vue3项目ts文件引入LodopFuncs.js打印控件
  19. 分享一个Java超市积分管理系统项目的制作方法。
  20. HDU 威威猫系列故事——篮球梦

热门文章

  1. 400w人在抖音学驾照科目一,给我看哭了……用Python这不一下整活了吗
  2. 关于拉格朗日坐标系求解要转为初始构型的讨论(1),为何欧拉坐标系不行。
  3. scrapy简单入门 - 爬取伯乐在线所有文章
  4. HTML css js成长路程
  5. 漫画算法-小灰的算法之旅-排序算法(四)
  6. ROS_java源码编译开发android APP项目
  7. 开放是一种激情――北京软件自由日纪实
  8. 使用Canvas 实现手机端签名
  9. Leetcode-SQL学习计划-SQL入门-584:寻找用户推荐人
  10. 我与世界杯的故事——达利奇:铜牌闪耀着金光