org.apache.ibatis.binding.BindingException: Invalid bound statement (not found): com.example......

本文探讨了MyBatis中BindingException错误的原因及解决方案,包括mapper接口与XML文件的匹配问题、路径配置不正确等常见问题,并提供了详细的排查步骤。

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

org.apache.ibatis.binding.BindingException: Invalid bound statement (not found): com.example......
发生这样的问题原因有以下几点
1.mapper接口类全名与mapper.xml的namespace不一致
2.mapper接口的方法与mapper.xml的id不一致
3.mapper.xml的中文注释造成(去掉中文注释)
4.mapper.xml的路径与配置的不一致
例如:
mapper.xml位置在resources/mapper/mapper.xml但是你的mybatis配置确是
(mybatis:
  mapperLocations: classpath:mapper/*/*.xml)
这样只能扫描到不到mapper/mapper.xml
正确的配置是
mybatis:
  mapperLocations: classpath:mapper/*.xml或者将mapper.xml放到resources/mapper/*/mapper.xml的位置(*表示任何文件夹名称)
5.idea中的resources有个标志如果没有则需要设置成resources
选择file-->Project Structure-->Moudules-->选择项目的resources文件夹-->点击Resources-->ok

如图


评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值