今天在用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. 洛谷 P4822 [BJWC2012]冻结

    之前没学分层图,所以先咕了一下hiahiahia. 学完分层图了回来水写题解了. 这道题要用分层图来解.分层图就是在我们决策的时候,再建k层图,一共k+1层,层与层之间是有向边(这个很重要的),权值为 ...

  2. Redundant Paths 分离的路径【边双连通分量】

    Redundant Paths 分离的路径 题目描述 In order to get from one of the F (1 <= F <= 5,000) grazing fields ...

  3. 浏览器的回流与重绘 (Reflow & Repaint)

    写在前面 在讨论回流与重绘之前,我们要知道: 浏览器使用流式布局模型 (Flow Based Layout). 浏览器会把HTML解析成DOM,把CSS解析成CSSOM,DOM和CSSOM合并就产生了 ...

  4. P1220 关路灯——区间dp

    P1220 关路灯 题目描述 某一村庄在一条路线上安装了 \(n\) 盏路灯,每盏灯的功率有大有小(即同一段时间内消耗的电量有多有少).老张就住在这条路中间某一路灯旁,他有一项工作就是每天早上天亮时一 ...

  5. redis 集群方案及搭建

    由于Redis出众的性能,其在众多的移动互联网企业中得到广泛的应用.Redis在3.0版本前只支持单实例模式,虽然现在的服务器内存可以到100GB.200GB的规模,但是单实例模式限制了Redis没法 ...

  6. 小师妹学JVM之:Dirty cards和PLAB

    目录 简介 分代收集器中的空间划分 Write barrier和Dirty cards PLAB old space分配对象 总结 简介 分代垃圾回收器在进行minor GC的时候会发生什么操作呢?有 ...

  7. SQL列转行,行转列实现

    在工作中,大家可能会遇到一些SQL列转行.行转列的问题,恰好,我也遇到了,就在此记录一下.此处所用的是SQLServer2008R2. 行转列,列转行,都要预先知道要要处理多少数据,在此我就以三种方案 ...

  8. 京东秋招提前批初试--java开发工程师

    1,自我介绍,学过的课程有哪些 2,介绍一下java的内存结构和内存模型(jvm和jmm) 3,对于NIO有没有了解?作用是什么?(基于通道和缓冲区的I/O方式,用的是DirectByteBuffer ...

  9. bzoj3687简单题*

    bzoj3687简单题 题意: 给个集合,求所有子集的元素和的异或和.集合元素个数≤1000,整个集合的元素和≤2000000 题解: 用bitset维护每个子集元素和的个数是奇数还是偶数.每次读入一 ...

  10. SpringBoot代码生成器

    Code-Generate 代码生成器 简介 一个基于原生Mysql & SpringBoot & Mybatis 的代码生成器,建表之后即可完全解放双手,适合: 规律性定制化开发 解 ...