总结解决 org.apache.ibatis.binding.BindingException: Invalid bound statement (not found)方法

问题背景:在做SpringBoot项目的时候,通过controller层调用service层的接口时出现了如下的报错

org.apache.ibatis.binding.BindingException: Invalid bound statement (not found): com.example.service.UserService.getByIdat org.apache.ibatis.binding.MapperMethod$SqlCommand.<init>(MapperMethod.java:235) ~[mybatis-3.5.2.jar:3.5.2]at com.baomidou.mybatisplus.core.override.MybatisMapperMethod.<init>(MybatisMapperMethod.java:49) ~[mybatis-plus-core-3.2.0.jar:3.2.0]at com.example.controller.UserController.obj(UserController.java:18) ~[classes/:na]

1.问题原因

通过网上搜索到的报错原因,本质原因是由于dao层(也可以叫做mapper接口)跟mapper.xml文件没有映射,而大部分的原因有如下的几种类型:

  1. dao层的方法跟mapper.xml的方法不一样
  2. mapper.xml中的namespace 要写对应的dao层和entity层不一样
  3. spring配置文件中mybatis与xml文件路径的配置没有写,导致无法映射成功
  4. 拼写错误导致

2.解决方法

2.1方法1:

Mypatis配置文件有问题,在application.yml添加如下代码:

mybatis-plus:mapper-locations: classpath*:com/example/mapper/xml/*Mapper.xml

mapper-locations的路径要对应响应 .xml 文件所在路径

2.2方法2:

在pom.xml 文件下加入如下代码:

<build>    <resources><resource><directory>src/main/java</directory><includes><include>**/*.properties</include><include>**/*.xml</include></includes><filtering>false</filtering></resource><resource><directory>src/main/resources</directory><includes><include>**/*.properties</include><include>**/*.xml</include></includes><filtering>false</filtering></resource></resources>
</build>

这上部分的解决方法应该能解决大部分的service层报错的问题,但是这上面的方法并不能解决我的问题。通过我继续对其研究,发现在我的一个扫描Mapper配置文件中路径错误


这是由于配置的base-package范围太大,导致service层的接口也被包装了,将base-package的范围缩小到dao层既可以解决了

将其修改到对应的dao层路径后问题就得以解决了

总结mybatis plus解决org.apache.ibatis.binding.BindingException: Invalid bound statement (not found)方法相关推荐

  1. 解决org.apache.ibatis.binding.BindingException: Invalid bound statement (not found)错误

    解决org.apache.ibatis.binding.BindingException: Invalid bound statement (not found)错误 2018年07月23日 16:5 ...

  2. IDEA异常解决: org.apache.ibatis.binding.BindingException: Invalid bound statement (not found)

    IDEA异常解决: org.apache.ibatis.binding.BindingException: Invalid bound statement (not found) 参考文章: (1)I ...

  3. 解决org.apache.ibatis.binding.BindingException: Invalid bound statement (not found):xxx问题

    文章目录 1. 复现问题 2. 分析问题 2.1 检查启动类的配置 2.2 检查xml文件对应java类的配置是否有误 2.3 检查application.yml文件的mybatis配置是否有误 2. ...

  4. (解决)org.apache.ibatis.binding.BindingException: Invalid bound statement (not found)问题的办法

    1.基础办法:先检查mapper和xml的本身的对应关系是否正确(包括路径指向,方法名,包名对应是否正确),如果使用的是idea可以借助插件MybatisPlugin,能连接到指定方法说明绑定是没有问 ...

  5. 解决org.apache.ibatis.binding.BindingException: Invalid bound statement (not found) 问题

    ######## 上述问题本论坛的解决办法也有几篇, 但是百密一疏我就是那个更low的菜鸟 同样也遇到了这个问题 30分钟才找到问题所在(只怪自己不够认真) 正文: 我的问题出现在方法二 使用代理对象 ...

  6. 解决org.apache.ibatis.binding.BindingException Invalid bound statement (not found) com.fs.mapper.UserM

    首先我们来看看我的修改前的Mapper.xml文件 <mapper namespace="com.fs.mapper.UserMapper"><select id ...

  7. 报错:org.apache.ibatis.binding.BindingException: Invalid bound statement (not found)问题

    记录报错:解决org.apache.ibatis.binding.BindingException: Invalid bound statement (not found)问题 在做毕设的时候,报了这 ...

  8. springboot整合Mybatis提示org.apache.ibatis.binding.BindingException: Invalid bound statement (not found)

    在用maven配置mybatis环境时出现此BindingExceptiony异常,发现在classes文件下没有mapper配置文件,应该是maven项目没有扫描到mapper包下的xml文件, 在 ...

  9. 解决:org.apache.ibatis.binding.BindingException: Invalid bound statement (not found) ...

    前些天发现了一个巨牛的人工智能学习网站,通俗易懂,风趣幽默,忍不住分享一下给大家.点击跳转到教程. org.apache.ibatis.binding.BindingException: Invali ...

最新文章

  1. 嵌入式视频处理考虑(一)
  2. 从微信红包的春节活动运营方案中,必读的运营策略
  3. 一个不用SD卡,不用livesuit的刷nand的想法
  4. 在idea 中添加和删除模块Module
  5. 做一个项目,平时都用到哪些工具提高效率(中)
  6. 【C语言】文件程序设计实践
  7. yum 更新内核报错 “Error: initscripts conflicts with centos-release-7-0.1406.el7.centos.2.3.x86_64的解决办法
  8. OkHttp3源码详解(五) okhttp连接池复用机制
  9. 401 un[Authorize]
  10. Q96:PT(2):纹理的仿射变换(Textures And Transformations)
  11. UVa 10791 Minimum Sum LCM
  12. Webstorm汉化方法
  13. hbase基本操作命令及练习
  14. K-mer特征提取one-hot编码
  15. Problem F: 求三角形面积-gyy
  16. 【朝花夕拾】Android自定义View篇之(十)移动阈值TouchSlop及滑动追踪VelocityTracker...
  17. MATLAB彩色图像读写
  18. 2048小游戏(网页版)
  19. Swift - 设置UILabel、UITextView的文字行间距
  20. 新手必备AutoCAD练习图纸,分分钟提高你的绘图效率!

热门文章

  1. python游戏设计_Python设计一个猜大小游戏
  2. 【websocket】springboot 实现 websocket
  3. 0110闭区间上连续函数的性质-函数与极限-高等数学
  4. R语言 数据处理 dplyr包 数据清理
  5. websocket协议以及在gin中的应用
  6. 朋友问我,你都30岁了学编程来得及吗
  7. “理想”有什么理想?
  8. 植物大战僵尸2付费分析
  9. Oracle 常规问题1000问
  10. 乱弹火影世界,影射现实生活