SpringBoot下使用tk.mapper遇到的小坑

本文记录了在SpringBoot项目中使用tk.mapper时遇到的bean注入问题,详细描述了从错误日志分析、模块结构排查到最后发现启动类目录配置不当导致MapperConfig未生效的解决过程,提醒开发者注意模块依赖及启动类位置对配置扫描的影响。

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

前言:在使用同事封装的自定义通用mapper接口工具模块时,出现扫描不到业务模块的mapper接口报出控制器、服务实现类依赖无法满足问题。

错误类似以下内容(当时并没有保存日志):

org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name ‘userController’: Unsatisfied dependency expressed through field ‘userMapper’; nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type ‘com.minibike.bike.user.dao.UserMapper’ available: expected at least 1 bean which qualifies as autowire candidate. Dependency annotations: {@org.springframework.beans.factory.annotation.Autowired(required=true)}”

1.从日志得到的信息

控制器、服务实现类的依赖无法满足是因为UserMapper这个bean没有被注入(可以从该句看出:expected at least 1 bean which qualifies as autowire candidate.)

2.大致的分析

既然UserMapper这个bean没有被装配成功,那么问题可能出现在Mapper包的扫描上。(mapper包

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值