成功解决:org.apache.ibatis.binding.BindingException: Invalid bound statement (not found): com.*.mapper.*

1.出现原因

在使用mybtis-plus框架开发时,实现mapper.xml写sql语句查询数据的时候,没有找到对应的mapper会出现这类错误。

2.排查过程

1.先仔细检查名字(方法名,类名)等,或者单词拼写有没有错误。
2.最后查看target编译之后的目录发现,mapper中的xml在不在【默认maven加载时,java类型的文件进行编译,非java文件不会加载】
在这里插入图片描述

3.解决方法:

1.赋值xml文件夹到target中。(不推荐)
2.把xml文件放到resource中。
3.通过配置实现(推荐)
在这里插入图片描述
三种方法任选其一:最后在yml中加上配置.

mybatis-plus:
#  configuration:
#    log-impl: org.apache.ibatis.logging.stdout.StdOutImpl
  mapper-locations: classpath:com/atguigu/serviceedu/mapper/xml/*Mapper.xml

猜你喜欢

转载自blog.csdn.net/weixin_46266624/article/details/130533365