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> 

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

版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/cjs520131499/article/details/75267236

mybatis错误:Invalid bound statement (not found)

今天向往常一样搭建一个spring-mybatis项目时,由于一开始dao 的路径写错了,于是手动修改路径,直接创建了一个叫com.XX.XX.XX的路径。启动项目的时候,总是报错。 Excepti...
  • wy1204126213
  • wy1204126213
  • 2017-07-27 11:49:11
  • 4121

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

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

org.apache.ibatis.binding.BindingException: Invalid bound statement (not found):

关于maven构建spring+Mybatis工程运行错误: org.apache.ibatis.binding.BindingException: Invalidbound statement (n...
  • u014104286
  • u014104286
  • 2016-09-28 10:24:06
  • 2735

(原创)常见报错不常见原因之——org.apache.ibatis.binding.BindingException: Invalid bound statement (not found)

错误日志:org.apache.ibatis.binding.BindingException: Invalid bound statement (not found)..... 常见原因:由于myb...
  • EgbertYu
  • EgbertYu
  • 2017-07-26 21:39:16
  • 2089

mybatis绑定错误:org.apache.ibatis.binding.BindingException: Invalid bound statement (not found)

org.apache.ibatis.binding.BindingException: Invalid bound statement (not found)错误经常遇到,意思就是mybatis绑定错...
  • qq_25821067
  • qq_25821067
  • 2016-10-07 19:03:12
  • 2639

org.apache.ibatis.binding.BindingException: Invalid bound statement (not found)解决

此问题有两种情况: 为Mabatis绑定错误 IDEA打包问题(如果在eclipse下面没有该问题,在IDEA存在,需要在pom.xml下面加上*Mapper.xml配置一起打包) Mybatis绑定...
  • wu6660563
  • wu6660563
  • 2016-09-07 15:04:57
  • 3523

BindingException: Invalid bound statement (not found) 错误解决办法

org.apache.ibatis.binding.BindingException: Invalid bound statement (not found) 错误的解决办法...
  • lyp5257918
  • lyp5257918
  • 2016-12-22 21:12:13
  • 874

出现org.apache.ibatis.binding.BindingException: Invalid bound statement (not found)的解决方法

出现org.apache.ibatis.binding.BindingException: Invalid bound statement (not found)的解决方法 以及Intellij部署项...
  • conleyfree
  • conleyfree
  • 2017-01-25 00:54:13
  • 28936

【问题解决】Maven搭建Web项目中org.apache.ibatis.binding.BindingException: Invalid bound statement (not found)问

最近使用Maven配合SSM(Spring+SpringMVC+Mybatis)搭建一个Web项目,在测试三个框架是否整合成功的时候,每次发出请求调用MyBatis时都会出现下面这个错误 ...
  • lisongjia123
  • lisongjia123
  • 2016-04-25 16:11:52
  • 3781

mybatis绑定错误

如果出现: org.apache.ibatis.binding.BindingException: Invalid bound statement (not found) 一般的原因是Mapper i...
  • softwarehe
  • softwarehe
  • 2013-05-06 10:14:35
  • 119099
收藏助手
不良信息举报
您举报文章:nvalid bound statement (not found)解决方法
举报原因:
原因补充:

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