您的位置:首页 > 运维架构 > Apache

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

2017-02-13 16:24 645 查看
今天在弄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(){

}


原因还有待探究。。。
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  mybatis
相关文章推荐