nvalid bound statement (not found)解决方法

原创 2017年07月17日 19:49:50

错误描述,smm项目出现:

org.apache.ibatis.binding.BindingException: Invalid bound statement (not found): org.seckill.dao.SeckillDao.queryById
    at org.apache.ibatis.binding.MapperMethod$SqlCommand.<init>(MapperMethod.java:189)
    at org.apache.ibatis.binding.MapperMethod.<init>(MapperMethod.java:43)
    at org.apache.ibatis.binding.MapperProxy.cachedMapperMethod(MapperProxy.java:58)
    at org.apache.ibatis.binding.MapperProxy.invoke(MapperProxy.java:51)
    at com.sun.proxy.$Proxy15.queryById(Unknown Source)
    at org.test.Test1.queryById1(Test1.java:21)
    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:498)
    at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:47)
    at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
    at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:44)
    at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:17)
    at org.springframework.test.context.junit4.statements.RunBeforeTestMethodCallbacks.evaluate(RunBeforeTestMethodCallbacks.java:74)
    at org.springframework.test.context.junit4.statements.RunAfterTestMethodCallbacks.evaluate(RunAfterTestMethodCallbacks.java:83)
    at org.springframework.test.context.junit4.statements.SpringRepeat.evaluate(SpringRepeat.java:72)
    at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.runChild(SpringJUnit4ClassRunner.java:232)
    at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.runChild(SpringJUnit4ClassRunner.java:89)
    at org.junit.runners.ParentRunner$3.run(ParentRunner.java:238)
    at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:63)
    at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:236)
    at org.junit.runners.ParentRunner.access$000(ParentRunner.java:53)
    at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:229)
    at org.springframework.test.context.junit4.statements.RunBeforeTestClassCallbacks.evaluate(RunBeforeTestClassCallbacks.java:61)
    at org.springframework.test.context.junit4.statements.RunAfterTestClassCallbacks.evaluate(RunAfterTestClassCallbacks.java:71)
    at org.junit.runners.ParentRunner.run(ParentRunner.java:309)
    at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.run(SpringJUnit4ClassRunner.java:175)
    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:678)
    at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:382)
    at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:192)

这样的错误你先仔细检查namespace里的路径是否正确,我这里产生这样报错的原因是因为在配置文件中写的mapping路径是

<!-- 自动扫描mapping.xml文件 -->
        <property name="mapperLocations" value="classpath:*Dao.xml"></property> 

改成

<!-- 自动扫描mapping.xml文件 -->
        <property name="mapperLocations" value="classpath*:*Dao.xml"></property>

就可以运行了,至于classpath:和classepath*:的区别简单说就是
classpath:只会到你的class路径中查找找文件;
classpath*:不仅包含class路径,还包括jar文件中(class路径)进行查找。
为了运行速度还是少尽量使用classpath*。
比如我在这里再建立一个文件夹叫mapper放置将映射文件放进去,再将路径改为

<property name="mapperLocations" value="classpath:/mapper/*Dao.xml"></property> 

这样也是可以运行的。
想要具体了解区别原因的请看我转载的这篇博客。

版权声明:本文为博主原创文章,未经博主允许不得转载。

相关文章推荐

[MyBatis]诡异的Invalid bound statement (not found)错误

自从开始使用Maven管理项目,最近在配置MyBatis的Mapper,在Eclipse上调试时都是正常的,但是最近把项目迁移到 IntelliJ IDEA 上后发现不管是直接用Jetty调试,还是打...

mybatis中定义mapper 出现bound statement (not found)

org.apache.ibatis.binding.BindingException: Invalid bound statement (not found): tgb.taotao.search.m...
  • lxy344x
  • lxy344x
  • 2016年07月14日 20:17
  • 3329

mybatis 异常处理:Invalid bound statement (not found)

mybatis 的使用过程中提示错误: org.apache.ibatis.binding.BindingException: Invalid bound statement (not found...

mybatis错误:Invalid bound statement (not found): com.prcsteel.peanut.dao.UserDao.selectById

Invalid bound statement (not found):

MyBatis Invalid bound statement

1. problem description Spring 3.2.x, MyBatis 3.1.x org.apache.ibatis.binding.BindingException: Inval...

mybatis 异常:Invalid bound statement (not found) .

Invalid bound statement (not found): me.tspace.pm.dao.UserDao.getUser     at org.apache.ibatis.bind...

关于mybatis “org.apache.ibatis.binding.BindingException: Invalid bound statement (not found)” 错误的问题。

关于mybatis “org.apache.ibatis.binding.BindingException: Invalid bound statement (not found)” 错误的问题。最近...

Invalid bound statement (not found)

Invalid bound statement (not found)

Invalid bound statement (not found)

mybatis报如下错误: org.apache.catalina.core.StandardWrapperValve.invoke Servlet.service() for servlet [d...

Mybatis - 在idea中错误:Invalid bound statement (not found)

学习mybatis的过程中,测试mapper自动代理的时候一直出错,在eclipse中可以正常运行,而同样的代码在idea中却无法成功。虽然可以继续调试,但心里总是纠结原因。百度了好久,终于找到一个合...
内容举报
返回顶部
收藏助手
不良信息举报
您举报文章:nvalid bound statement (not found)解决方法
举报原因:
原因补充:

(最多只允许输入30个字)