There is no getter for property named ‘xxxxx’ in ‘class com.xxx.xx.xx.xxxx‘”,
原文链接: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‘”,相关推荐
- 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这 ...
- 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 ...
- 解决There is no getter for property named 'xxx' in 'classxxxx'
今天在做新增时遇到的报错. Caused by: org.apache.ibatis.reflection.ReflectionException: There is no getter for pr ...
- mybatis报错There is no getter for property named '***' in 'class ***'
mybatis报错There is no getter for property named '***' in 'class ***', 检查一看是xml中映射字段拼写错误,大小写. 有的时候用插件生 ...
- mybaits错误解决:There is no getter for property named 'parentId ' in class 'java.lang.String'
在使用mybaitis传参数的时候,如果仅传入一个类型为String的参数,那么在 xml文件中应该使用_parameter来代替参数名. 比如mapper中如下方法,只有一个String值 publ ...
- 异常处理: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 ...
- 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 ...
- Mybatis中传参包There is no getter for property named XXX in class java.lang.String
一.发现问题 <select id="queryStudentByNum" resultType="student" parameterType=&quo ...
- 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 ...
最新文章
- 华为python工程师工资-华为工程师对Python编程的看法
- 【Netty】NIO 网络编程 聊天室案例
- We Chall-Training: Get Sourced-Writeup
- 使用Notepad++工具查看文件的十六进制
- java arraystoreexception_208道高频 Java面试题答案6
- Linux和Window下生成以年月日时分秒为名称的文件。
- dr.oracle素颜霜好用吗,treechada素颜霜好用吗_treechada素颜霜评测
- BIOS设置开机密码
- Java学习笔记——函数式接口
- Redis官网——如何利用Redis做服务器集群的分布式锁
- 小米为什么拆分红米? | 畅言
- JAVA里static 变量在程序执行结束后是否被消毁
- 制作CDKEY:CDKEY不宜包含生效时间
- 互联网公司起名,其实都有套路的!
- 360度不停旋转动画demo效果示例(整理)
- 美团买菜助手来了,自动点击,助你买菜
- 空间句法软件sDNA安装教程及加载到ArcGIS方法
- 淘宝店铺商品接口 item_search_shop数据获取、拼多多关键词、1688原数据接口、淘宝商品详情sku信息等各大电商平台接口采集调用展示
- 【游戏人生】一个游戏程序员的学习资料
- 任意多边形的面积公式