org.apache.ibatis.executor.ExecutorException: No constructor found in com.contentsales.meta.User

今天在弄mybatis的时候,出现下面这个错误:

Exception in thread "main" org.mybatis.spring.MyBatisSystemException: nested exception is org.apache.ibatis.executor.ExecutorException: No constructor found in com.contentsales.meta.User matching [java.lang.Integer, java.lang.String, java.lang.String, java.lang.Integer]

我的User类代码如下:

public class User {
    private int id;
    private String name;
    private String password;
    private int type;
    public User(int  id,String name,String password,int type){
        this.id=id;
        this.name=name;
        this.password=password;
        this.type=type;
    }

看报错信息是说没有找到符合的构造函数,它需要[java.lang.Integer, java.lang.String, java.lang.String, java.lang.Integer],也就是说原始类型int和对象类型Integer是需要区分的,使用下面两种方案就可以解决:
1. 将这个构造函数的int原始类型改成Integer,即改成public User(Integer id,String name,String password,Integer type)
2. 不改的话,就在代码中再加上一个默认的构造函数,即添加

    public User(){

    }

原因还有待探究。。。

评论 6
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

zlp1992

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值