SpringBoot org.apache.ibatis.binding.BindingException: Invalid bound statement (not found): mapper.xxxMapper.xxx() 错误解决

起因:今天练习 SpringBoot 下 Mybatis 使用的时候报了一个奇怪的错误

org.apache.ibatis.binding.BindingException: Invalid bound statement (not found): mapper.CustomerMapper.getAllCustomers

网上看了一下资料,出现这个问题有两个原因:

  • Mapper  接口内方法和 Mapper 配置文件 内法名不匹配
  • IDEA Mapper 配置文件和 Mapper 同路径,导致测试程序时 target 目录下只有 xxxMapper.class 文件,而缺失 xxxMapper.xml 文件

我首先排除了第一种可能性,那么如何解决此问题呢?

需要在 resourse 文件下新建 同 Mapper 接口相同的目录层级,并将Mapper 配置文件 copy 过来即可;

再次运行程序,问题解决;

猜你喜欢

转载自www.cnblogs.com/wdh01/p/12815036.html
今日推荐