日本免费高清视频-国产福利视频导航-黄色在线播放国产-天天操天天操天天操天天操|www.shdianci.com

學無先后,達者為師

網站首頁 編程語言 正文

MyBatis There is no getter for property named ‘xxx‘ in ‘class xxx‘問題解決

作者:embelfe_segge 更新時間: 2022-02-21 編程語言

問題描述:

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;
}

原文鏈接:https://blog.csdn.net/embelfe_segge/article/details/123191204

欄目分類
最近更新