总结mybatis plus解决org.apache.ibatis.binding.BindingException: Invalid bound statement (not found)方法
总结解决 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文件没有映射,而大部分的原因有如下的几种类型:
- dao层的方法跟mapper.xml的方法不一样
- mapper.xml中的namespace 要写对应的dao层和entity层不一样
- spring配置文件中mybatis与xml文件路径的配置没有写,导致无法映射成功
- 拼写错误导致
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)方法相关推荐
- 解决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 ...
- IDEA异常解决: org.apache.ibatis.binding.BindingException: Invalid bound statement (not found)
IDEA异常解决: org.apache.ibatis.binding.BindingException: Invalid bound statement (not found) 参考文章: (1)I ...
- 解决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. ...
- (解决)org.apache.ibatis.binding.BindingException: Invalid bound statement (not found)问题的办法
1.基础办法:先检查mapper和xml的本身的对应关系是否正确(包括路径指向,方法名,包名对应是否正确),如果使用的是idea可以借助插件MybatisPlugin,能连接到指定方法说明绑定是没有问 ...
- 解决org.apache.ibatis.binding.BindingException: Invalid bound statement (not found) 问题
######## 上述问题本论坛的解决办法也有几篇, 但是百密一疏我就是那个更low的菜鸟 同样也遇到了这个问题 30分钟才找到问题所在(只怪自己不够认真) 正文: 我的问题出现在方法二 使用代理对象 ...
- 解决org.apache.ibatis.binding.BindingException Invalid bound statement (not found) com.fs.mapper.UserM
首先我们来看看我的修改前的Mapper.xml文件 <mapper namespace="com.fs.mapper.UserMapper"><select id ...
- 报错:org.apache.ibatis.binding.BindingException: Invalid bound statement (not found)问题
记录报错:解决org.apache.ibatis.binding.BindingException: Invalid bound statement (not found)问题 在做毕设的时候,报了这 ...
- springboot整合Mybatis提示org.apache.ibatis.binding.BindingException: Invalid bound statement (not found)
在用maven配置mybatis环境时出现此BindingExceptiony异常,发现在classes文件下没有mapper配置文件,应该是maven项目没有扫描到mapper包下的xml文件, 在 ...
- 解决:org.apache.ibatis.binding.BindingException: Invalid bound statement (not found) ...
前些天发现了一个巨牛的人工智能学习网站,通俗易懂,风趣幽默,忍不住分享一下给大家.点击跳转到教程. org.apache.ibatis.binding.BindingException: Invali ...
最新文章
- 嵌入式视频处理考虑(一)
- 从微信红包的春节活动运营方案中,必读的运营策略
- 一个不用SD卡,不用livesuit的刷nand的想法
- 在idea 中添加和删除模块Module
- 做一个项目,平时都用到哪些工具提高效率(中)
- 【C语言】文件程序设计实践
- yum 更新内核报错 “Error: initscripts conflicts with centos-release-7-0.1406.el7.centos.2.3.x86_64的解决办法
- OkHttp3源码详解(五) okhttp连接池复用机制
- 401 un[Authorize]
- Q96:PT(2):纹理的仿射变换(Textures And Transformations)
- UVa 10791 Minimum Sum LCM
- Webstorm汉化方法
- hbase基本操作命令及练习
- K-mer特征提取one-hot编码
- Problem F: 求三角形面积-gyy
- 【朝花夕拾】Android自定义View篇之(十)移动阈值TouchSlop及滑动追踪VelocityTracker...
- MATLAB彩色图像读写
- 2048小游戏(网页版)
- Swift - 设置UILabel、UITextView的文字行间距
- 新手必备AutoCAD练习图纸,分分钟提高你的绘图效率!