问题现象:
之前在项目中遇到一个bug,报错如下:
org.ibatis.binding.BindingException: Invalid bound statement (not found): com.xxxxxxxxx.mappers.xxxMapper
问题分析:
从报错信息可知报错意思大概是:
mybatis绑定异常:找不到这个xxxMapper接口对应的xxxMapper.xml文件.
直接定位到这个xxxMapper接口去看一下:
没什么问题,再去这个Mapper接口对应的xml文件看看:
这下就可以知道问题所在了:
这是因为两个文件不同名,在mybatis中需要保证Mapper接口和Mapper.xml文件是同名的,如果名字是Dao接口,则必须是同名的Daoxml文件; (注意: 即使在xml文件中配置了正确的映射接口路径也不行, 必须保证文件名同名)
解决方法:
保证两个文件同名即可: