org.mybatis.spring.MyBatisSystemException: nested exception is org.apache.ibatis.executor.ExecutorEx

在弄springboot整合Mybatis时遇到了下面的异常:

org.mybatis.spring.MyBatisSystemException: nested exception is org.apache.ibatis.executor.ExecutorException: No constructor found in com.example.demo.entity.User matching [java.lang.Long, java.sql.Timestamp, java.lang.String]

意思说在com.example.demo.entity.User里没有匹配的构造函数
我的User类代码:

import java.util.Date;

public class User implements Serializable {
    private static final Long serialVersionUID=8655851615465363473L;

    private Long id;

    private String userName;

    private Date date;

    public User(String userName, Date date) {
        this.userName = userName;
        this.date = date;
    }

    public User(Long id, String userNam, Date date) {
        this.id=id;
        this.userName = userName;
        this.date = date;
    }

解决方法:
1,把java.util.Date换为java.sql.Date,就是把构造函数改成相匹配的类型

import java.sql.Date;

public class User implements Serializable {
    private static final Long serialVersionUID=8655851615465363473L;

    private Long id;

    private String userName;

    private Date date;

    public User(String userName, Date date) {
        this.userName = userName;
        this.date = date;
    }

    public User(Long id, String userNam, Date date) {
        this.id=id;
        this.userName = userName;
        this.date = date;
    }

2,添加一个无参构造函数;

public class User implements Serializable {
    private static final Long serialVersionUID=8655851615465363473L;

    private Long id;

    private String userName;

    private Date date;

    public User() {
    }

    public User(String userName, Date date) {
        this.userName = userName;
        this.date = date;
    }

    public User(Long id, String userNam, Date date) {
        this.id=id;
        this.userName = userName;
        this.date = date;
    }
评论 3
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值