org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name

一个原本正常运行的Spring Boot项目,添加新的jar包和Java文件后报错,报错类型为依赖注入失败。原因是Autowired找不到DAO注入的对象。解决办法包括检查报错路径、扫描dao包路径、mybatis plus扫描实体类路径以及mapper.xml文件配置是否正确。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

起因:

之前的正常运行的springboot项目,添加了新的jar包和新的java文件,结果就出现了这个问题 

报错详情:

org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'openController': Unsatisfied dependency expressed through field 'clientService'; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'clientService': Unsatisfied dependency expressed through field 'baseMapper'; nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type 'com.huban.app.dao.ClientDao' available: expected at least 1 bean which qualifies as autowire candidate. Dependency annotations: {@org.springframework.beans.factory.annotation.Autowired(required=true)}
原因:

Autowired  找不到 DAO 注入的对象

我的解决办法

1、查看报错的路径ClientDao路径是否正确、配置的扫描dao包路径是否正确(我的是扫描路径错误)

2、查看mybatis plus配置的 扫描实体类路径是否正确

3、去到mybatis plus的mapper.xml 文件夹下面查看对应Dao的xml文件是否配置错误(我的是下xml配置错误,之前的xml忘了删除导致的)

 

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值