mybatis-plus调用自身的 selectById 方法报错:org.apache.ibatis.binding.BindingException:
mybatis-plus的版本号是 2.0.1,在调用自身的insert(T)的时候没有报错,但是执行update报错,调用selectById、deleteById的时候也报错。也就是涉及到需要主键识别的都报错。
语句如下:(接口与实现都是MP自己实现的)
User selectById = userMapper1.selectById("ceshi");
userMapper1.deleteById("ceshi");
报错信息如下:
org.apache.ibatis.binding.BindingException: Invalid bound statement (not found): cn.xm.jwxt.ceshi.mapper.UserMapper.deleteById
at org.apache.ibatis.binding.MapperMethod$SqlCommand.<init>(MapperMethod.java:230)
at org.apache.ibatis.binding.MapperMethod.<init>(MapperMethod.java:48)
at org.apache.ibatis.binding.MapperProxy.cachedMapperMethod(MapperProxy.java:65)
at org.apache.ibatis.binding.MapperProxy.invoke(MapperProxy.java:58)
at com.sun.proxy.$Proxy18.deleteById(Unknown Source)
at cn.xm.jwxt.ceshi.MpTest.test1(MpTest.java:30)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:606)
at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:44)
at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:15)
at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:41)
at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:20)
at org.springframework.test.context.junit4.statements.RunBeforeTestMethodCallbacks.evaluate(RunBeforeTestMethodCallbacks.java:75)
at org.springframework.test.context.junit4.statements.RunAfterTestMethodCallbacks.evaluate(RunAfterTestMethodCallbacks.java:86)
at org.springframework.test.context.junit4.statements.SpringRepeat.evaluate(SpringRepeat.java:84)
at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:263)
at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.runChild(SpringJUnit4ClassRunner.java:254)
at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.runChild(SpringJUnit4ClassRunner.java:89)
at org.junit.runners.ParentRunner$3.run(ParentRunner.java:231)
at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:60)
at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:229)
at org.junit.runners.ParentRunner.access$000(ParentRunner.java:50)
at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:222)
at org.springframework.test.context.junit4.statements.RunBeforeTestClassCallbacks.evaluate(RunBeforeTestClassCallbacks.java:61)
at org.springframework.test.context.junit4.statements.RunAfterTestClassCallbacks.evaluate(RunAfterTestClassCallbacks.java:70)
at org.junit.runners.ParentRunner.run(ParentRunner.java:292)
at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.run(SpringJUnit4ClassRunner.java:193)
at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:86)
at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:459)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:675)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:382)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:192)
原因:如果是自己手写的接口,没写SQL或者说是SQL的XML的namespace写错的话可以找出原因,可是这是MP自己实现的,自己都没动接口。
经检查,在实体类中,不对主键字段添加 @TableId("数据库字段名称") 注解的话,在调用涉及id的自带方法时就出现此错误。估计是mybatis-plus无法识别主键字段。
解决办法:声明数据库的主键列名称就可以了
所以,建议如果使用Mybatis-Plus的话,最好在实体类中详细注解好表名称(@TableName)、表主键(@TableId),以免出现这种很难找到原因的错误。
另:据说新版本mybatis-plus已经解决此问题
mybatis-plus调用自身的 selectById 方法报错:org.apache.ibatis.binding.BindingException:的更多相关文章
- 报错org.apache.ibatis.binding.BindingException: Type interface com.atguigu.mybatis.bean.dao.EmployeeMapper is not known to the MapperRegistry.
报错org.apache.ibatis.binding.BindingException: Type interface com.atguigu.mybatis.bean.dao.EmployeeMa ...
- Maven项目使用mybatis报错 org.apache.ibatis.binding.BindingException: Invalid bound statement (not found):
maven项目使用mybatis时,找不到mapper文件(.xml) 错误信息提示: 项目可以正常运行,但是在有请求到达服务器时(有访问数据库的请求),会出现报错!! 错误原因: mybatis没有 ...
- mybatis plus 报错 org.apache.ibatis.binding.BindingException: Invalid bound statement (not found)
org.apache.ibatis.binding.BindingException: Invalid bound statement (not found) 少了个范型
- 【mybatis】mybatis访问报错:org.apache.ibatis.binding.BindingException: Invalid bound statement (not found) 或者 feign被调用方使用的mybatis总报空指针异常java.lang.NullPointerException,而变量都没有问题的情况
mybatis访问报错:org.apache.ibatis.binding.BindingException: Invalid bound statement (not found) 需要检查的步骤: ...
- 初学者手册-MyBatis踩坑记(org.apache.ibatis.binding.BindingException)
1.参数绑定失败 org.mybatis.spring.MyBatisSystemException: nested exception is org.apache.ibatis.binding.Bi ...
- 【spring boot Mybatis】报错:org.apache.ibatis.binding.BindingException: Invalid bound statement (not found): com.newhope.interview.dao.UserMapper.add
报错如下: org.apache.ibatis.binding.BindingException: Invalid bound statement (not found): com.newhope.i ...
- mybatis使用时org.apache.ibatis.binding.BindingException: Invalid bound statement (not found):的错误
最近在使用mybatis时,出现了 org.apache.ibatis.binding.BindingException: Invalid bound statement (not found): 这 ...
- org.mybatis.spring.MyBatisSystemException: nested exception is org.apache.ibatis.binding.BindingException: Parameter 'username' not found. Available parameters are [1, 0, param1, param2]
Spring+mybatis错误:org.mybatis.spring.MyBatisSystemException: nested exception is org.apache.ibatis.bi ...
- 怪事年年有,今天特别多!org.mybatis.spring.MyBatisSystemException: nested exception is org.apache.ibatis.binding.BindingException: Parameter 'empno' not found. Available parameters are [emp, deptno, param1, param
错误: org.mybatis.spring.MyBatisSystemException: nested exception is org.apache.ibatis.binding.Binding ...
随机推荐
- String 类中的几个练习--获取指定字符串中,大写字母、小写字母、数字的个数||获取一个字符串中,另一个字符串出现的次数
package cn.homework.demo1; public class GetCount { /* * 获取一个字符串中,另一个字符串出现的次数 * 思想: * 1. indexOf到字符串中 ...
- Linux系统诊断必备技能之一:lsof 用法详解!
lsof(list open files)是一个查看当前系统文件的工具.在linux环境下,任何事物都以文件的形式存在,用户通过文件不仅可以访问常规数据,还可以访问网络连接和硬件:如传输控制协议 (T ...
- bzoj3991 LCA + set
https://www.lydsy.com/JudgeOnline/problem.php?id=3991 小B最近正在玩一个寻宝游戏,这个游戏的地图中有N个村庄和N-1条道路,并且任何两个村庄之间有 ...
- TF的使用
激活函数 关于激活函数的介绍请参考:激活函数 这里只是记录TF提供的激活函数 import tensorflow as tf a = tf.nn.relu( tf.matmul(x, w1) + ...
- 【leetcode-125】 验证回文串
给定一个字符串,验证它是否是回文串,只考虑字母和数字字符,可以忽略字母的大小写. 说明:本题中,我们将空字符串定义为有效的回文串. 示例 1: 输入: "A man, a plan, a c ...
- Android获取版本号
public static String getVersionName(Context context) { PackageManager manager = context.getPackageMa ...
- FFI
FFI概念 https://segmentfault.com/t/ffi/info FFI即Foreign Function Interface,外部函数调用接口,是一个语言提供的使用其他语言现有库( ...
- 【bzoj 1143】[CTSC2008]祭祀river
Description 在遥远的东方,有一个神秘的民族,自称Y族.他们世代居住在水面上,奉龙王为神.每逢重大庆典, Y族都会在水面上举办盛大的祭祀活动.我们可以把Y族居住地水系看成一个由岔口和河道组成 ...
- Tensorflow Python 转 Java(一)
一.背景描述 最近python的tensorflow想办法给弄到线上去.网络用的Tensorflow现成的包.写篇博客,记录下过成.数据用kaggle中的数据为例子. 数据地址: https://ww ...
- “无法找到XXX.exe的调试信息,或调试信息不匹配”解决方案
错误信息如下: 解决方法: 选择项目属性,依次序进行如下操作. 1.选择 配置属性->链接器->调试->生成调试信息 改为 是 一般问题都是出现在这个地方,修改完了可以尝试运行,若还 ...