Mybatis-Plus mapper扫描路径问题

今天重新搭建SpringBoot项目融合MybatisPlus遇到一个问题“org.apache.ibatis.binding.BindingException: Invalid bound statement (not found)”,这个问题是MybatisPlus没有扫描到mappers.xml引起的,解决方法如下:

  • SpringBoot启动类Application加入注解 @MapperScan("com.package.mapper") ,这个是指向src目录中的mapper而非mapper.xml
  • 检查application.properties中mapper-locations: classpath:/mapper/*Mapper.xml ,注意是 xxx/xxx/*Mapper.xml 而不是 xxx.xxx.xxx
  • pom导包为 mybatis-plus-boot-starter
原文地址:https://www.cnblogs.com/liaoweiming/p/13904725.html