原文链接:https://www.longkui.site/program/java/getter/5082/

0.背景
SpringMVC架构,使用mybatis执行insert语句,然后开始报错:

org.mybatis.spring.MyBatisSystemException: nested exception is org.apache.ibatis.reflection.ReflectionException: There is no getter for property named ‘xxxxx’ in ‘class com.xxx.xxx.api.xxxx’”,

mapper层的写法:

void insertStudent(Student student);
xml层的写法:

insert into stu(id,name) values (#{id},#{name}) 然后就开始报上面的错误了。

1.问题原因及解法方法
实体类缺失getter/setter 方法。 解决办法,加入getter/setter方法
实体类名与数据库类名不符。这个一般遇不到,而且可以不一定要对应。
实体类名与 xml 中的 property 名不符, xml 中 column 名与 property 名不符。 解决办法: 这个如果你要做一一对应的话就写成一样的,要不然自己写参数对应也行。
编写 sql 语句不要多空格少逗号之类的,不要写错少些字母。解法办法:请仔细检查sql语句。
最后,就是我实际遇到的,mapper层和xml层写错了。

上面的mapper层代码应该改成下面这样:

void insertStudent(@Param(“student”) Student student);
xml层应该改成下面这样:

insert into stu(id,name) values (#{student.id},#{student.name}) PS: 不要过度依赖代码生成器,有的代码自己写两遍才知道问题所在。

There is no getter for property named ‘xxxxx’ in ‘class com.xxx.xx.xx.xxxx‘”,相关推荐

  1. Mybatis-no getter for property named 'col_name' in 'class com.xxx.onebean'

    Mybatis中出现该异常 There is no getter for property named 'col_name' in 'class com.xxx.onebean 意思是onebean这 ...

  2. There is no getter for property named xxx in xxx

    这里记录一下bug.使用mybatis报错! 启动项目是正常的,访问报错: 2020-06-30 11:38:28.988 | ERROR | | | http-nio-8080-exec-1 -&g ...

  3. 解决There is no getter for property named 'xxx' in 'classxxxx'

    今天在做新增时遇到的报错. Caused by: org.apache.ibatis.reflection.ReflectionException: There is no getter for pr ...

  4. mybatis报错There is no getter for property named '***' in 'class ***'

    mybatis报错There is no getter for property named '***' in 'class ***', 检查一看是xml中映射字段拼写错误,大小写. 有的时候用插件生 ...

  5. mybaits错误解决:There is no getter for property named 'parentId ' in class 'java.lang.String'

    在使用mybaitis传参数的时候,如果仅传入一个类型为String的参数,那么在 xml文件中应该使用_parameter来代替参数名. 比如mapper中如下方法,只有一个String值 publ ...

  6. 异常处理:Mybatis报错:There is no getter for property named ‘xxxx‘ in ‘class xxx‘

    异常处理:Mybatis报错:There is no getter for property named 'xxxx' in 'class xxx' 参考文章: (1)异常处理:Mybatis报错:T ...

  7. MyBatis3: There is no getter for property named 'code' in 'class java.lang.String'

    mybatis3  : mysql文如下,传入参数为string类型时'preCode',运行报错为:There is no getter for property named 'preCode' i ...

  8. Mybatis中传参包There is no getter for property named XXX in class java.lang.String

    一.发现问题 <select id="queryStudentByNum" resultType="student" parameterType=&quo ...

  9. Mybatis问题:There is no getter for property named 'unitId' in 'class java.lang.String'

    Mybatis遇到的问题 问题: org.mybatis.spring.MyBatisSystemException: nested exception is org.apache.ibatis.re ...

最新文章

  1. 华为python工程师工资-华为工程师对Python编程的看法
  2. 【Netty】NIO 网络编程 聊天室案例
  3. We Chall-Training: Get Sourced-Writeup
  4. 使用Notepad++工具查看文件的十六进制
  5. java arraystoreexception_208道高频 Java面试题答案6
  6. Linux和Window下生成以年月日时分秒为名称的文件。
  7. dr.oracle素颜霜好用吗,treechada素颜霜好用吗_treechada素颜霜评测
  8. BIOS设置开机密码
  9. Java学习笔记——函数式接口
  10. Redis官网——如何利用Redis做服务器集群的分布式锁
  11. 小米为什么拆分红米? | 畅言
  12. JAVA里static 变量在程序执行结束后是否被消毁
  13. 制作CDKEY:CDKEY不宜包含生效时间
  14. 互联网公司起名,其实都有套路的!
  15. 360度不停旋转动画demo效果示例(整理)
  16. 美团买菜助手来了,自动点击,助你买菜
  17. 空间句法软件sDNA安装教程及加载到ArcGIS方法
  18. 淘宝店铺商品接口 item_search_shop数据获取、拼多多关键词、1688原数据接口、淘宝商品详情sku信息等各大电商平台接口采集调用展示
  19. 【游戏人生】一个游戏程序员的学习资料
  20. 任意多边形的面积公式

热门文章

  1. Labview发布web service时出现错误 Error LabVIEW: (Hex 0xFFFEFA29)
  2. MYSQL:指定时间删除过期数据
  3. Python|画出一个300像素的十字架
  4. 关于学习VUEX的学习记录
  5. Java实现区块链 --- 代码篇
  6. 英语里面关于钱数量的单词有哪些
  7. bugku------啊哒(纯小白)
  8. web安全之弱口令漏洞学习总结
  9. 一对一视频社交app如何达到最好的效果
  10. 关于九宫格密码的思考