0
点赞
收藏
分享

微信扫一扫

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

玉字璧 2022-02-20 阅读 91
前端html

问题描述:

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 id="create">
        INSERT INTO t_user(user_id,user_name,data_time)
        VALUES (#{item.userId,item.userName,item.dataTime})
    </insert>

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

解决办法:

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

    <insert id="create">
        INSERT INTO t_user(user_id,user_name)
        VALUES (#{item.userId,item.userName})
    </insert>

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

public class UserDto {
    private Long userId;
    private String userName;
    private Date dataTime;
}
举报

相关推荐

Java UnknownHostException: xxx问题解决

0 条评论