栏目分类:
子分类:
返回
名师互学网用户登录
快速导航关闭
当前搜索
当前分类
子分类
实用工具
热门搜索
名师互学网 > IT > 软件开发 > 后端开发 > Java

MyBatis There is no getter for property named ‘xxx‘ in ‘class xxx‘问题解决

Java 更新时间: 发布时间: IT归档 最新发布 模块sitemap 名妆网 法律咨询 聚返吧 英语巴士网 伯小乐 网商动力

MyBatis There is no getter for property named ‘xxx‘ in ‘class xxx‘问题解决

问题描述:

org.mybatis.spring.MyBatisSystemException: nested exception is org.apache.ibatis.reflection.ReflectionException: There is no getter for property named ‘dataTime’ in ‘class com.dto.UserDto’

问题分析:

1、Mapper文件中参数出现了dataTime,但是实体类UserDto中却没有dataTime,两边无法映射导致报错。

    
        INSERT INTO t_user(user_id,user_name,data_time)
        VALUES (#{item.userId,item.userName,item.dataTime})
    

public class UserDto {
    private Long userId;
    private String userName;
}

解决办法:

(1)Mapper文件去掉dataTime,实体类保持不变。

    
        INSERT INTO t_user(user_id,user_name)
        VALUES (#{item.userId,item.userName})
    

(2)实体中添加dataTime,Mapper文件保持不变。

public class UserDto {
    private Long userId;
    private String userName;
    private Date dataTime;
}
转载请注明:文章转载自 www.mshxw.com
本文地址:https://www.mshxw.com/it/750723.html
我们一直用心在做
关于我们 文章归档 网站地图 联系我们

版权所有 (c)2021-2022 MSHXW.COM

ICP备案号:晋ICP备2021003244-6号