您的位置:首页 > 其它

关于mybatis Invalid bound statement (not found) 问题

2016-04-14 21:31 591 查看


 org.apache.ibatis.binding.BindingException: Invalid bound statement (not found): org.benpaobang.system.mapper.version.VersionMapper.queryCurrentVersion

at org.apache.ibatis.binding.MapperMethod$SqlCommand.<init>(MapperMethod.java:196)

at org.apache.ibatis.binding.MapperMethod.<init>(MapperMethod.java:44)

at org.apache.ibatis.binding.MapperProxy.cachedMapperMethod(MapperProxy.java:59)

at org.apache.ibatis.binding.MapperProxy.invoke(MapperProxy.java:52)

at com.sun.proxy.$Proxy61.queryCurrentVersion(Unknown Source)

at org.benpaobang.system.service.impl.version.VersionService.queryCurrentVersion(VersionService.java:36)

at org.benpaobang.system.service.impl.version.VersionService$$FastClassBySpringCGLIB$$a8f0d3a2.invoke(<generated>)

at org.springframework.cglib.proxy.MethodProxy.invoke(MethodProxy.java:204)

at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.invokeJoinpoint(CglibAopProxy.java:717)

at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:157)

at org.springframework.transaction.interceptor.TransactionInterceptor$1.proceedWithInvocation(TransactionInterceptor.java:99)

at org.springframework.transaction.interceptor.TransactionAspectSupport.invokeWithinTransaction(TransactionAspectSupport.java:281)

at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:96)

at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179)

at org.springframework.aop.interceptor.ExposeInvocationInterceptor.invoke(ExposeInvocationInterceptor.java:92)

at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179)

at org.springframework.aop.framework.CglibAopProxy$DynamicAdvisedInterceptor.intercept(CglibAopProxy.java:653)

at org.benpaobang.system.service.impl.version.VersionService$$EnhancerBySpringCGLIB$$f521447d.queryCurrentVersion(<generated>)

at org.benpaobang.system.controller.impl.version.VersionController.getCurrentVersion(VersionController.java:31)

at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)

at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)

at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)

at java.lang.reflect.Method.invoke(Method.java:483)

at org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:302)

at org.springframework.aop.framework.ReflectiveMethodInvocation.invokeJoinpoint(ReflectiveMethodInvocation.java:190)

at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:157)

at org.benpaobang.core.intercept.ValidInterceptor.invoke(ValidInterceptor.java:64)

at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179)

at org.benpaobang.system.utils.GetUserIdByTokenProxy.invoke(GetUserIdByTokenProxy.java:41)

at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179)

at org.springframework.aop.interceptor.ExposeInvocationInterceptor.invoke(ExposeInvocationInterceptor.java:92)

at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179)

at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:207)

at com.sun.proxy.$Proxy94.getCurrentVersion(Unknown Source)

at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)

at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)

at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)

at java.lang.reflect.Method.invoke(Method.java:483) 

针对这个问题,网上很多的解决办法如下:
1.Configuration.xml的mappers属性

2.POJO的mapper接口如EmployeeMapper的类路径

3.<mapper namespace="me.tspace.pm.dao.userdao">  mapper的namespace写的不对!!!

4.mapper XML文件中没有对应的方法,或者方法名称没有对应。

5.mapper XML文件中返回值与接口里返回值类型不同。

6.mapper XML文件异常-->导致编译异常,请任意修改下对应的xml文件,比如删除一个空行,保存。

但是经过仔细的检查,发现我并没有犯以上错误。
所以继续找问题,最后发现是由于我的mapper类与对应的XML名字不一导致的,如下图。

内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息