记一个因resources路径引发的org.apache.ibatis.binding.BindingException: Invalid bound statement (not found)
阅读本文需要 5 分钟
前言
通常来说,这个 org.apache.ibatis.binding.BindingException: Invalid bound statement (not found) 就是接口的方法找不到对应Mapper文件的statementId(namespace + id)
常规的排查方法可以看这篇文章 链接
但我的情况比较特殊,最后从这篇文章发现蛛丝马迹 链接
原因是resources下的路径有【.】和【\】的区别
问题还原
- IDEA 下,在resources 创建
com.example.dao
- 如果装了mybatis的插件,如 Free Mybatis plugin,Mapper接口是能够跳转到xml的
- 然后把xml文件移进去,编译,查看target
可以看到 resources 的文件被单独拿出来了,没有跟mapper接口编译在一起
也尝试过用 resources
标签,编译特定后缀的文件,但也不能解决
问题解决
- IDEA下,在resources 创建
com\example\dao
- 然后把xml文件移进去,编译,查看target
然后就在一起了 一 ^ 一,接下来能正常运行