// 未分类
【CrudBoy的奇妙冒险】跑了一年的代码报错Invalid bound statement
发布 2022-11-10 · 永久链接
跑了一年的代码报错。。。
``` bash
022-11-10 17:22:19.628 [http-nio-60051-exec-6] ERROR c.g.p.e.ExceptionProcessHandler - Invalid bound statement (not found): xx业务Mapper.selectBatchIds
org.apache.ibatis.binding.BindingException: Invalid bound statement (not found): xx业务Mapper.selectBatchIds
at org.apache.ibatis.binding.MapperMethod$SqlCommand.(MapperMethod.java:235)
at com.baomidou.mybatisplus.core.override.MybatisMapperMethod.(MybatisMapperMethod.java:50)
at com.baomidou.mybatisplus.core.override.MybatisMapperProxy.lambda$cachedInvoker$0(MybatisMapperProxy.java:111)
at java.util.concurrent.ConcurrentHashMap.computeIfAbsent(Unknown Source)
at com.baomidou.mybatisplus.core.toolkit.CollectionUtils.computeIfAbsent(CollectionUtils.java:115)
at com.baomidou.mybatisplus.core.override.MybatisMapperProxy.cachedInvoker(MybatisMapperProxy.java:98)
at com.baomidou.mybatisplus.core.override.MybatisMapperProxy.invoke(MybatisMapperProxy.java:89)
at com.sun.proxy.$Proxy120.selectBatchIds(Unknown Source)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:344)
at org.springframework.aop.framework.ReflectiveMethodInvocation.invokeJoinpoint(ReflectiveMethodInvocation.java:198)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:163)
at org.springframework.dao.support.PersistenceExceptionTranslationInterceptor.invoke(PersistenceExceptionTranslationInterceptor.java:137)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:186)
at com.baomidou.dynamic.datasource.aop.DynamicDataSourceAnnotationInterceptor.invoke(DynamicDataSourceAnnotationInterceptor.java:50)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:186)
at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:215)
at com.sun.proxy.$Proxy121.selectBatchIds(Unknown Source)
```
原本的代码
``` java
@DS("xxxx")
public List getxx业务s(List uid) {
return xx业务Mapper.selectBatchIds(uid);
}
```
可能原因
#### 1.mapper.xml 里面的 namespace与实际类不一样
排查,一致
#### 2.mapper接口的函数名称和mapper.xml里面的标签id不一致
selectBatchIds 是com.baomidou.mybatisplus.core.mapper.BaseMapper 的默认方法
修复的代码
``` java
@DS("xxxx")
public List getxx业务s(List uid) {
return xx业务Mapper.selectList(new LambdaQueryWrapper()
.in(xx业务::getUid, uid)
);
}
```