springboot整合mybaits过程中,调用接口时报错:org.apache.ibatis.binding.BindingException: Invalid bound statement (not found):

SpringBoot整合mybatis踩坑

 

  分析了下报错堆栈信息,认为是找不到*Mapper.xml导致,网上搜索下他人博客,以为是IDEA导致*Mapper.xml无法生成,于是检查了编译生成的classes目录(classpath),发现*Mapper.xml是存在的,IDEA并没有问题。
  就在百思不得其解时,仔细检测了下application.yml文件中mybatis的基本配置,大吃一惊,原来自己配置时不小心多了空格缩进,把mybatis的配置加到spring配置属性上了。因此,mybatis配置不生效,导致mybatis扫描不到Mapper.xml文件,因此运行时报“mapper接口与mapper.xml绑定异常”。

SpringBoot整合mybatis踩坑

 

小结:

  “mapper接口与mapper.xml绑定异常”的一种原因,就是mybatis配置有误导致程序找不到mapper.xml文件(即:属性mapperLocations配置有问题),因此报错。

 

相关文章:

  • 2021-11-06
  • 2021-11-15
  • 2021-08-01
  • 2021-06-15
  • 2021-06-03
  • 2021-09-14
  • 2021-12-28
  • 2021-12-12
猜你喜欢
  • 2021-08-08
  • 2022-01-07
  • 2021-06-18
  • 2022-12-23
  • 2022-12-23
  • 2022-01-25
相关资源
相似解决方案