一、异常信息

Caused by: org.apache.ibatis.binding.BindingException: Invalid bound statement (not found): com.hand.hec.nghec.sys.mapper.SysServiceMapper.selectService
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.$Proxy169.selectService(Unknown Source)
at com.hand.hec.nghec.sys.service.impl.SysServiceServiceImpl.select(SysServiceServiceImpl.java:26)
at com.hand.hec.nghec.sys.service.impl.SysServiceServiceImpl.select(SysServiceServiceImpl.java:1)
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.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:333)
at org.springframework.aop.framework.ReflectiveMethodInvocation.invokeJoinpoint(ReflectiveMethodInvocation.java:190)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:157)
at com.hand.hap.core.impl.ServiceExecutionAdvice.invoke(ServiceExecutionAdvice.java:169)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179)
at org.springframework.transaction.interceptor.TransactionInterceptor$1.proceedWithInvocation(TransactionInterceptor.java:99)
at org.springframework.transaction.interceptor.TransactionAspectSupport.invokeWithinTransaction(TransactionAspectSupport.java:282)
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.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:213)
at com.sun.proxy.$Proxy170.select(Unknown Source)
at com.hand.hap.system.controllers.BaseController.query(BaseController.java:68)

二、异常原因

一般的原因是Mapper interface和xml文件的定义对应不上,

需要检查包名,namespace,函数名称等能否对应上,

需要比较细致的对比,我经常就是写错了一两个字母搞的很长时间找不到错误

三、异常解决过程

1.常见解决方法

出现这个错误时,按以下步骤检查一般就会解决问题:

1:检查xml文件所在的package名称是否和interface对应的package名称一一对应

2:检查xml文件的namespace是否和xml文件的package名称一一对应

3:检查函数名称能否对应上

4:去掉xml文件中的中文注释

5:随意在xml文件中加一个空格或者空行然后保存

一般来说到此就可以排除错误了

2.我的原因与解决方法

(1)原因

原因还是因为Mapper interface和xml文件的定义对应不上

这是因为我一个web工程依赖了两个jar工程,而这两个jar工程 mapper.xml文件的目录结构相似,并且映射路径也相同,这导致mybatis只扫描了其中一个jar工程的xml,而不扫描另一个的。

applicationContext.xml

jar工程1目录:

jar工程2目录:

 (2)解决方法

修改applicationContext.xml 中 mapper文件映射路径:

写成两个就可以了

(3)存疑

如上述配置文件中,mybatis  一个 value  只扫一个工程的。 所以要为每个工程单独配置一个value.

四、参考资料

1.mybatis绑定错误-- Invalid bound statement (not found)

Mybatis异常_03_Invalid bound statement (not found)的更多相关文章

  1. Mybatis异常_01_Invalid bound statement (not found)

    异常信息:org.apache.ibatis.binding.BindingException: Invalid bound statement (not found): com.taotao.map ...

  2. 解决Mybatis的invalid bound statement (not found)异常

    使用Maven构建SSM时, 需要在pom.xml中配置一些信息, 否则mapper.xml就无法被扫描到, 程序就会抛invalid bound statement (not found)异常 解决 ...

  3. mybatis-plus 异常 Invalid bound statement (not found)

    最近吧项目中添加使用了mybatis-plus,发现操作sql的时候出现异常: Invalid bound statement (not found) ,异常位置位于mybatis-plus的jar中 ...

  4. mybatis:Invalid bound statement (not found)

    [常规解决办法] 如果出现: org.apache.ibatis.binding.BindingException: Invalid bound statement (not found) 一般的原因 ...

  5. MyBatis错误--Invalid bound statement (not found)

    今天在开发项目的时候使用MyBatis发生错误:Invalid bound statement (not found) 具体错误信息: org.springframework.beans.factor ...

  6. mybatis错误Invalid bound statement (not found) 的解决办法

    <!-- IDEA需要添加一下内容,否则无法找到mapper --> <build> <resources> <resource> <direct ...

  7. myBatis中Invalid bound statement (not found)错误

    环境:Idea.ssm.maven 由于使用maven的原因,maven不会扫描到mapper的xml文件所以会出现此类问题. 每次走到mapper方法时就抛异常:Invalid bound stat ...

  8. mybatis 报Invalid bound statement(not found) 和 Property 'mapperLocations' was not specified or not matching resources found

    排除问题的步骤: 1.首先检查mapper文件和mapper接口的文件名是否相等. 2.pom.xml是否把xml排除了,这样写就会src/main/java下所有的Mybatis的xml文件都删除, ...

  9. mybatis BindingException: Invalid bound statement (not found)

    错误截图 解决措施 此异常的原因是由于mapper接口编译后在同一个目录下没有找到mapper映射文件而出现的. 通常我们在配置SqlSessionFactory时会有如配置 <!-- 配置Sq ...

随机推荐

  1. HTML5-SQLLite连接

    1.代码部分(可直接粘贴到html文件中运行) <body onload="init()"> 姓名:<input type="text" id ...

  2. C语言八进制和十六进制数

    一 赋值 int dex = 100;// 默认十进制 int oct = 0144;// 八进制,以0開始 int hex = 0x64;// 十六进制,以0x開始 二 输出 void show(i ...

  3. Ruby之Rspec的报错解决

    #enconding:utf-8 require 'selenium-webdriver' require 'rspec' describe "baidu main page" d ...

  4. Linux在中国正在走向没落

    在中国,Linux正在走向没落,一片萧条景象. 在这样的大背景下.居然有人愿意接手中科红旗,令人佩服! 在中国,没有一个关于国际Linux的官方刊物(或站点)反映国际Linux运动的真实声音.Linu ...

  5. Scrapy教程

    Scrapy教程 原文地址https://doc.scrapy.org/en/latest/intro/tutorial.html 此教程我们假设你已经装好了Scrapy,如果没有请查看安装指南.. ...

  6. less1.5中的减错误

    (@bodywidth)-@leftwidth即在第一个变量外加括号---正确 @bodywidth-@leftwidth即直接使用不加括号--------错误

  7. c++引用返回值

    引用作为函数的返回值时,函数的返回值能够理解为函数返回了一个变量(事实上,函数返回引用时,它返回的是一个指向返回值的隐式指针),因此,值为引用的函数能够用作赋值运算符的左操作数.另外,用引用返回一个函 ...

  8. gitlab多人协同工作

    gitlab多人协同工作 本文为亨利向<Git权威指南>的作者蒋鑫老师的答疑邮件写成. 这里特别感谢蒋鑫老师对我询问gitlab的协同工作流程问题的详细解答. 蒋鑫老师的细致专业的解答让我 ...

  9. Mysql 索引增加与删除

    [1]索引 索引,通俗理解,即目录. 之前说过,计算机是对现实世界的模拟.目录应用在数据库领域,即所谓的索引. 目录的作用显而易见,所以建立索引可以大大提高检索的速度. 但是,会降低更新表的速度,如对 ...

  10. 五个知识体系之-SQL学习-第二天

    创建数据:INSERT INTO userinfo(userid,username,job,level1,companyage) VALUES ('001','xl001','test','P1',' ...