org.apache.ibatis.binding.BindingException【原因汇总】
这个问题整整纠结了我四个多小时,心好累啊。。。不废话。。。
背景:Spring整合Mybatis
报错:org.apache.ibatis.binding.BindingException: Invalid bound statement (not found)
解释:就是说,你的Mapper接口,被Spring注入后,却无法正常的使用mapper.xml的sql;
这里的Spring注入后的意思是,你的接口已经成功的被扫描到,但是当Spring尝试注入一个代理(MyBatista实现)的实现类后,却无法正常使用。这里的可能发生的情况有如下几种;
- 接口已经被扫描到,但是代理对象没有找到,即使尝试注入,也是注入一个错误的对象(可能就是null)
- 接口已经被扫描到,代理对象找到了,也注入到接口上了,但是调用某个具体方法时,却无法使用(可能别的方法是正常的)
当然,我们不好说是那种情况,毕竟报错的结果是一样的,这里就提供几种排查方法:
- mapper接口和mapper.xml是否在同一个包(package)下?名字是否一样(仅后缀不同)?
- 比如,接口名是NameMapper.java;对应的xml就应该是NameMapper.xml
- mapper.xml的命名空间(namespace)是否跟mapper接口的包名一致?
- 比如,你接口的包名是com.abc.dao,接口名是NameMapper.java,那么你的mapper.xml的namespace应该是com.abc.dao.NameMapper
- 接口的方法名,与xml中的一条sql标签的id一致
- 比如,接口的方法List<User> findAll();那么,对应的xml里面一定有一条是<select id="findAll" resultMap="**">****</select>
- 如果接口中的返回值List集合(不知道其他集合也是),那么xml里面的配置,尽量用resultMap(保证resultMap配置正确),不要用resultType
- 最后,如果你的项目是maven项目,请你在编译后,到接口所在目录看一看,很有可能是没有生产对应的xml文件,因为maven默认是不编译的,因此,你需要在你的pom.xml的<build></build>里面,加这么一段:
- <resources>
- <resource>
- <directory>src/main/java</directory>
- <includes>
- <include>**/*.xml</include>
- </includes>
- <filtering>true</filtering>
- </resource>
- </resources>
我就是坑在了第5点上,折腾了四个多小时,大家及时发现。
org.apache.ibatis.binding.BindingException【原因汇总】的更多相关文章
- Spring扫面路径配置不全导致异常 org.apache.ibatis.binding.BindingException: Invalid bound statement (not found): 的原因
运行Junit测试类 package cn.bgodata.x.zero.service; import org.junit.Test; import org.junit.runner.RunWith ...
- org.apache.ibatis.binding.BindingException: Invalid bound statement (not found):
org.apache.ibatis.binding.BindingException: Invalid bound statement (not found): da.huying.usermanag ...
- Exception:HTTP Status 500 - org.apache.ibatis.binding.BindingException: Invalid bound statement (not found)
主要错误信息如下: HTTP Status 500 - org.apache.ibatis.binding.BindingException: Invalid bound statement (not ...
- mybatis使用时org.apache.ibatis.binding.BindingException: Invalid bound statement (not found):的错误
最近在使用mybatis时,出现了 org.apache.ibatis.binding.BindingException: Invalid bound statement (not found): 这 ...
- IDEA异常解决: org.apache.ibatis.binding.BindingException: Invalid bound statement (not found)
有时候解决问题不仅仅是解决问题.-----jstarseven 最近因为开发需要,需要搭建一个ssm开发框架,采用了开发工具IDEA. 整合完了SSM开发框架之后,发布的时候出现org.apache. ...
- MyBatis 传List参数 nested exception is org.apache.ibatis.binding.BindingException: Parameter 'idList' not found.
在MyBatis传入List参数时,MyBatis报错:nested exception is org.apache.ibatis.binding.BindingException: Paramete ...
- org.apache.ibatis.binding.BindingException: Invalid bound statement (not found): com.shen.mapper.UserMapper.findById
org.apache.ibatis.binding.BindingException: Invalid bound statement (not found): com.shen.mapper.Use ...
- mybatis错误之org.apache.ibatis.binding.BindingException: Invalid bound statement (not found)
玩了MyBatis差不多有两年了,中间也玩过MyBatis-Plus,这个MyBatis-Plus其实与MyBatis的区别并不大.今天写博客业务代码的时候,犯一个初学者犯过的错误. 错误信息如下:o ...
- maven项目 报错 org.apache.ibatis.binding.BindingException: Invalid bound statement (not found):
ssm的项目如果在mapper.xml mapper接口 配置没问题的情况下 项目依然报org.apache.ibatis.binding.BindingException: Invalid bo ...
随机推荐
- 阿里大于短信服务_异常_01_InvalidTimeStamp.Expired
一.异常信息 dm.aliyuncs.com InvalidTimeStamp.Expired Specified time stamp or date value is expired. 二.异常原 ...
- Confd 配置指导
Quick Start Guide Before we begin be sure to download and install confd. Select a backend confd supp ...
- <十七>UML核心视图动态视图之时序图
一:时序图 --->时序图是用于描述按时间顺序排列的对象之间的交互模式. --->它按照参与交互的对象所具有的“生命线”和他们相互发送的消息来显示这些对象. --->时序图包含对象和 ...
- 【Lintcode】013.strStr
题目: For a given source string and a target string, you should output the first index(from 0) of targ ...
- redis设置密码和redis主从复制
redis设置密码和redis主从复制 一.redis设置密码 1.Redis实用特性 安全性 主从复制(侦听器)事务处理 持久化机制 发布订阅消息 2.安全性:设置客户端连接后进行任何其他指定前需 ...
- 有趣的Javascript:只需一个JS让万恶的IE5、IE6、IE7、IE8全都支持H5原生Canvas绘图(有演示demo)
该demo支持IE5以上任意内核的浏览器 查看演示demo:支持IE5以上版本的浏览器Canvas绘图demo 补充:chats.js和echarts等图表库也可以使用本方法兼容IE6以上浏览器 1. ...
- PowerShell 总结
PowerShell 总结 1. 2. 3. 参考学习资料 (1). PowerShell 在线教程 (2). 利用Powershell在IIS上自动化部署网站 视频教程: (3). Windows ...
- POJ1144(割点入门题)
Network Time Limit: 1000MS Memory Limit: 10000K Total Submissions: 11378 Accepted: 5285 Descript ...
- Jasper:用户指南 / 设备 / 生命周期管理 / SIM 卡状态
ylbtech-Jasper:用户指南 / 设备 / 生命周期管理 / SIM 卡状态 1.返回顶部 1. SIM 卡状态 每个设备都有一个状态,决定了它能否在网络上建立数据连接,并且会影响设备是否计 ...
- Springboot学习七 spring的一些注解
一 事务控制 @Service public class CityServiceImpl implements CityService { @Autowired private CityMapper ...