今天在用Mybatis的时,写测试验证插入操作时出现错误org.apache.ibatis.reflection.ReflectionException: There is no getter for property named XXX。

根据字面意思就是我没有为XXX属性写getter方法,课我检查实体类却未发现有漏写情况出现,遂检查配置文件。

我在我自己的mybatis-config.xml文件中发现一行代码:

<setting name="mapUnderscoreToCamelCase" value="true"/>

上图是Mybatis官方文档的解释,也就是如果在XML文件中提前规定了把数据库中字段自动对应到Java中的驼峰命名(如果没有上面那行代码则只需要把实体类中的属性名称与数据库一一对应,但这样不利于命名规范)。

这时检查自己编写SQL语句的配置文件,果然,实体类的一个属性createTime在配置的时候写错了(也就是和实体类中的名称不同了,如下)

    <insert id="addBlog" parameterType="blog">
insert into blog (id,title,author,create_time,views)
values (#{id},#{title},#{author},#{createTime},#{views});
</insert>   <!--其中数据库中的 create_time 对应于 Java 实体类中的 createTime -->

org.apache.ibatis.reflection.ReflectionException: There is no getter for property named XXX 异常的解决办法。(亲测,一次成功!) #Mybatis的更多相关文章

  1. 已解决: mybatis报错 org.apache.ibatis.reflection.ReflectionException: There is no getter for property named 'xxx' in 'class java.lang.String'

    最近在练习MyBatis时 进行姓名的模糊查询时候出现 org.apache.ibatis.exceptions.PersistenceException: ### Error querying da ...

  2. Caused by: org.apache.ibatis.reflection.ReflectionException: There is no getter for property named 'zoneId' in 'class java.lang.String'

    本文为博主原创,未经允许不得而转载: 异常展示: dao层定义的接口为: public int getClientTotal(); 在mybatis中的sql为: <select id=&quo ...

  3. org.apache.ibatis.reflection.ReflectionException: There is no getter for property named 'list' in 'c

     org.apache.ibatis.reflection.ReflectionException: There is no getter for property named 'list' in ' ...

  4. org.apache.ibatis.reflection.ReflectionException: There is no getter for property named 'parentId' in 'class java.lang.String'

    Caused by: org.apache.ibatis.reflection.ReflectionException: There is no getter for property named ' ...

  5. mybatis之org.apache.ibatis.reflection.ReflectionException: There is no getter for property named 'time' in 'class java.lang.String'

    mybatis接口 List<String> getUsedCate(String time); 配置文件 <select id="getUsedCate" pa ...

  6. Mybatis笔记四:nested exception is org.apache.ibatis.reflection.ReflectionException: There is no getter for property named 'id' in 'class java.lang.String'

    错误异常:nested exception is org.apache.ibatis.reflection.ReflectionException: There is no getter for pr ...

  7. Caused by: org.apache.ibatis.reflection.ReflectionException: There is no getter for property named 'company' in 'class java.lang.String'

    Caused by: org.apache.ibatis.reflection.ReflectionException: There is no getter for property named ' ...

  8. 【Mybatis】mybatis查询报错org.apache.ibatis.reflection.ReflectionException: There is no getter for property named 'areaName' in 'class java.lang.String'

    mybatis查询报错: Caused by: org.apache.ibatis.reflection.ReflectionException: There is no getter for pro ...

  9. Cause: org.apache.ibatis.reflection.ReflectionException: There is no getter for property named 'empid' in 'class cn.happy.entity.Emp'

    org.apache.ibatis.exceptions.PersistenceException: ### Error querying database.  Cause: org.apache.i ...

随机推荐

  1. MyEclipse 选中属性或方法后 相同的不变色

    myeclipse-->windows-->java-->Editor-->content Assist-->Mark Occurrencmyeclipse-->w ...

  2. Python分析最近大火的网剧《隐秘的角落》,看看网友们有什么看法

    前言 本文的文字及图片来源于网络,仅供学习.交流使用,不具有任何商业用途,版权归原作者所有,如有问题请及时联系我们以作处理. 估计最近很火的连续剧<隐秘的角落>大家趁着端午假期都看过了吧? ...

  3. Python之浅谈生成器

    目录 三元表达式 列表推导式 字典生成式 生成器 生成器表达式 匿名函数 三元表达式 a=0 b=6 print (a)if a>b else print(b) 三元表达式只能写if的双分支结构 ...

  4. 自定义PHPstorm快捷键

    这篇随笔介绍一下PHPstorm自定义快捷键的步骤: 1.点击主菜单 File 下的 setting : 2.在弹出框中点击 Keymap : 3.之后会出现如下图所示的界面(图中所有的菜单都折叠了) ...

  5. tyvj 1198 矩阵连乘——区间dp

    tyvj 1198 矩阵连乘 题目描述 一个n*m矩阵由n行m列共n*m个数排列而成.两个矩阵A和B可以相乘当且仅当A的列数等于B的行数.一个N*M的矩阵乘以一个M*P的矩阵等于一个N*P的矩阵,运算 ...

  6. mac篇---mac安装jupyter

    1.Jupyter搭建 pip install --user jupyter 如果是在python3中,则用如下命令: pip3 install --user jupyter 如下图所示: 2. Ju ...

  7. Creator填色游戏的一种实现方案

    前言 先上一个辛苦弄出来的gif效果.写公众号时间不长,很多技巧还在慢慢跟小伙伴学习.可关注公众号,回复"绘图"或者"填色"都可获得demo的git地址.请使用 ...

  8. (数据科学学习手札89)geopandas&geoplot近期重要更新

    本文示例代码及数据已上传至我的Github仓库https://github.com/CNFeffery/DataScienceStudyNotes 1 简介 最近一段时间(本文写作于2020-07-1 ...

  9. 【GIT】git详解

    目录 一.基础使用 二.分支管理 三.提交树操作 四.复杂工作流处理 ----------------------------------------------------------------- ...

  10. JVM 专题十八:垃圾回收(二)垃圾回收相关算法

    1. 标记阶段 1.1 引用计数算法 1.1.1 对象存活判断 在堆里存放着几乎所有的Java对象实例,在GC执行垃圾回收之前,首先需要区分出内存中哪些是存活对象,哪些是已经死亡的对象.只有被标记为己 ...