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


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM