Parameter 0 of constructor in XXX required a bean of type ‘XXX‘ that could not be found.
今天在搭建微服务项目的时候遇到了一个问题
项目结构
实际的场景是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.相关推荐
- 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 ...
- 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 ...
- 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 ...
- 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 ...
- 使用Feign服务远程调用项目启动时报错:Field xxx in xxx required a bean of type xxx that could not be found.
报错: *************************** APPLICATION FAILED TO START ***************************Description:F ...
- 解决: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 ...
- 解决: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 ...
- spring boot报错:Parameter 4 of constructor in xx required a bean of type ‘xx‘ that could not be found.
spring boot 项目启动服务时,报错: 根据报错提示,一直认为是 SpringBootApplication 没有扫描到对应的 bean 路径. 最后,仔细排查发现是粗心的问题,自定义的常量没 ...
- 【踩坑专栏】Field xxFeignClient in xxx required a bean of type ‘xxx.XXFeignClient‘ that could not be found
首先我的feignClient上已标注解@FeignClient,出现这个问题的原因是因为启动类需要注解@EnableFeignClients(basePackages = "xx.xx.x ...
最新文章
- SAP QM IDI Interface
- 【Visual Studio 扩展工具】使用ComponentOne中的GroupDefinition和SortDefinition属性保存和还原布局...
- 研发工作中芯片选型需要考虑的问题
- jzoj4231-寻找神格【线段树,数学】
- Python爬虫自学之第(①)篇——爬虫伪装和反“反爬”
- 引用数据类型的方法调用
- 这个顶级AI赛事总奖池100W+!CV 、NLP赛题等你来战!
- VisualGDB系列10:快速调试Linux应用程序
- 第三天 LINUX安全
- php连接oracle设定字符集,避免乱码
- android实现标题栏弹框,Android:Dialog对话框、Builder、showDialog、模板方法设计模式...
- Could not connect to any servers in your MongoDB Atlas cluster. One common reason is that you‘re try
- FastReport 2021版中文手册PDF下载
- 爬虫学习——初步了解爬虫
- C++移动输出端的光标代码实现
- 在线教育投融数据(2015-2020年)
- 开发人员选择驻场有什么好处
- vue3项目ts文件引入LodopFuncs.js打印控件
- 分享一个Java超市积分管理系统项目的制作方法。
- HDU 威威猫系列故事——篮球梦