关于mapper.xml 的异常 BindingException: Invalid bound statement (not found)

  1. 问题
    SpringBoot 整合mybatis-plus 项目中,编写SQL语句自定义方法操作数据,xml文件放在src/main/java目录下,未成功执行自定义方法,报BindingException

  2. 分析
    编译后 target 目录下只有 class 文件,没有 mapper.xml;因为maven工程在默认情况下,不发布src/main/java 目录下的资源文件到target目录下

  3. 解决(两步即可)
    3.1 pom中配置如下
    在这里插入图片描述
    3.2 在Spring Boot配置文件中添加配置

     #配置mapper xml文件的路径
    mybatis-plus.mapper-locations=classpath:包路径/*.xml
    

猜你喜欢

转载自blog.csdn.net/weixin_51681634/article/details/110958314