在配置MyBatis时报错信息如下:

Invalid bound statement (not found): com.shizongger.chapter2.mapper.UserMapper.insertUser

简单的理解就是找不到正确的语句。一般是由于mapper.xml和mapper.java的文件不匹配造成的。引入映射器大致有四种方法:

1.用文件路径引入映射器

        <mapper resource="com/shizongger/chapter2/mapper/RoleMapper.xml" />
        <mapper resource="com/shizongger/chapter2/mapper/UserMapper.xml" />

2.用包名引入映射器

<package name="com.shizongger.chapter2.mapper" />

3.用类注册引入映射器

        <mapper class="com.shizongger.chapter2.mapper.UserMapper" />
        <mapper class="com.shizongger.chapter2.mapper.RoleMapper"/>

4.xxxMapper.xml引入映射器

        <mapper url="file:/home/shizongger/workspace/Chapter3/src/com/shizongger/chapter2/mapper/RoleMapper.xml" />
        <mapper url="file:/home/shizongger/workspace/Chapter3/src/com/shizongger/chapter2/mapper/UserMapper.xml"/>

这四种引入mapper的方式各有特点,我建议使用第一种或者第二种使用扫描的包的方式。但是在使用第二种的时候要注意:一定要把xxxMapper.java和xxxMapper.xml两者名字一模一样!

本次报错的原因是因为本人把UserMapper.xml错写成userMapper.xml,开头使用了小写,导致程序扫描包的时候扫描不到该mapper而出错。

我为什么会犯此错误?因为我在参考《深入浅出MyBatis技术原理与实践》(电子工业出版社-杨开振著)第3章57页的时候,作者给出了userMapper.xml的代码案例,并以小写作为userMapper.xml文件的开头。且在72页用到mapper.xml的地方,作者都有小写作为mapper.xml开头的习惯。本人误认为是MyBatis默认要求符合驼峰命名法且第一字母必须小写而导致的。

所以,在这里奉劝写技术书籍的作者不要浮躁,要对得起读者啊!

Invalid bound statement (not found): com.shizongger.chapter2.mapper.UserMapper.insertUser 解决方案的更多相关文章

  1. Invalid bound statement (not found): com.my.demo.mapper.UserMapper.getAll

    网上的方法全试了,配置全对,很奇怪. 最后一查,竟然忘记把mapper保存为xml格式. 记录一下.

  2. org.apache.ibatis.binding.BindingException: Invalid bound statement (not found): cn.e3mall.search.mapper.ItemMapper.getItemList

    java.lang.RuntimeException: org.apache.ibatis.binding.BindingException: Invalid bound statement (not ...

  3. Invalid bound statement (not found) 找不到mapper 映射文件异常

    访问页面报如下错(注意第一行后面的 invalid bound statement (not found)) 这时候再mapper的pom.xml文件要加如下. 否则该节点mybatis的mapper ...

  4. Invalid bound statement (not found): com.example.managerdemo.mapper.SingleTableMapper.selectAllValuesByConditionsNoPage

    报Invalid bound statement (not found): com.example.managerdemo.mapper.SingleTableMapper.selectAllValu ...

  5. 【spring boot Mybatis】报错:org.apache.ibatis.binding.BindingException: Invalid bound statement (not found): com.newhope.interview.dao.UserMapper.add

    报错如下: org.apache.ibatis.binding.BindingException: Invalid bound statement (not found): com.newhope.i ...

  6. 奇葩问题:Invalid bound statement (not found): cn.zss.zsdemo.mapper.RoleMapper.selectByPrimaryKey

    使用mybatis,遇到Invalid bound statement (not found): cn.zss.zsdemo.mapper.RoleMapper.selectByPrimaryKey ...

  7. 解决Invalid bound statement (not found)(Mybatis的Mapper绑定问题)

    一.问题描述 使用mybatis的项目在本地可以正常运行,但当使用maven或Jenkins打包部署到服务器上时出现了绑定错误,异常信息为: org.apache.ibatis.binding.Bin ...

  8. Mybatis中的Caused by: org.apache.ibatis.binding.BindingException: Invalid bound statement (not found): 找不到Mapper.xml文件的问题

    1 首先在配置mapper-locations的时候: classpath:  只在现有目录下寻找配置文件 classpath*: 在现有的项目目录下和依赖的jar包下寻找xml配置文件

  9. Invalid bound statement (not found): com.up.sell.mapper.system.H5operationMapper.

    springboot + mybatis项目,出现这样的错误原因就是mapper类的名字和xml的id不对应或者是忘记写了,仔细检查一下吧

随机推荐

  1. 走近Java

    学习Java需要了解必要的Java历史,不要觉得Java历史对学习Java编程没有任何帮助.在任何时候,了解一门语言的历史都能帮助更好地理解这门语言的精髓.以前在学习语文时,在分析一篇文章,通常会通过 ...

  2. TCP头部分析与确认号的理解

    1.TCP的特点: 基于字节流面向连接可靠传输缓冲传输全双工流量控制 2.头部格式和说明 图源百度.如下图示,就是TCP包的头部结构.可以看到这个头部最少有4x5=20个字节. 另外还需要理解TCP协 ...

  3. CAN通讯的总结

    1.CAN通讯有套国际标准,套协议版本号,种故障状态,种数据帧类型,种总线错误类型. 2.CAN的国际标准有两种ISO11898和ISO11519. 3.CAN2.0协议分为A版和B版两种,A版协议仅 ...

  4. 側滑回退的layout(相似IOS側滑回退到上一个activity)

    用过apple的同学应该都知道,大多数IOS应用都支持側滑回退,就不具体说明了,直接上图: 作为使用ios的android开发人员来说,我是特别喜欢这个功能的.既然这样,那就在android上也实现这 ...

  5. hibernate 映射组成关系

    建立域模型和关系数据模型有着不同的出发点: 域模型: 由程序代码组成, 通过细化持久化类的的粒度可提高代码的可重用性, 简化编程 在没有数据冗余的情况下, 应该尽可能降低表的数目, 简化表之间的參照关 ...

  6. 谈谈PBOC3.0中使用的国密SM2算法

    转载请注明出处 http://blog.csdn.net/pony_maggie/article/details/39780825 作者:小马 一 知识准备 SM2是国密局推出的一种他们自己说具有自主 ...

  7. 【python】函数闭包

    列表时可以改

  8. 【二十四】使用mysqli扩展类批量执行多条sql语句

    批量处理多个sql语句 <?php //批量执行多个dml语句 // $mysqli=new mysqli("localhost","root",&quo ...

  9. 从初识Maven到使用Maven进行依赖管理和项目构建

    前些天就安装了Maven,以备自己以后整合项目用,尤其是我们的ssh,ssm项目.想必好多人在开始的时候并不清楚Maven是什么,它能够帮助我们干什么. 所以在学习Maven之前我们一定要知道它是什么 ...

  10. iOS 让图片变模糊

    #import <Accelerate/Accelerate.h> 1.初始化图片 UIImageView *iv = [[UIImageView alloc]initWithFrame: ...