Mybatis-No constructor found

来源:互联网 发布:abbyy finereader mac 编辑:程序博客网 时间:2024/05/22 01:49

No constructor found

Entity

public class MyClass{   private Long id;   private Date create;   private String content;   MyClass (Long id, Date create, String content)   {       this.id = id;       this.create = create;       this.content = content;   }   //getters and setters}
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15

Mapper

 @Select("SELECT * FROM MyTable WHERE id=#{id}")   MyClass getMyClass (@Param("id") Long id);
  • 1
  • 2
  • 3

@Results(value = {      @Result(column = "id", property = "id", javaType = Long.class),      @Result(column = "create", property = "create", javaType = Date.class),      @Result(column = "content", property = "content", javaType = String.class)   })
  • 1
  • 2
  • 3
  • 4
  • 5

此时运行测试将会报错,即No constructor found **

解决方法

添加无参构造器以及各个getter/setter字段

阅读全文
0 0
原创粉丝点击