错误总结-myBatis plus 分页
今天碰到了一个神奇的问题:
org.mybatis.spring.MyBatisSystemException: nested exception is org.apache.ibatis.exceptions.PersistenceException:
### Error querying database. Cause: java.lang.IndexOutOfBoundsException: Index: 2, Size: 2
### The error may exist in cn/edu/zucc/sso/dao/RoleDao.java (best guess)
### The error may involve cn.edu.zucc.sso.dao.RoleDao.selectPage
### The error occurred while handling results
### SQL: SELECT role_id,role_name FROM role LIMIT ?,?
### Cause: java.lang.IndexOutOfBoundsException: Index: 2, Size: 2
当前使用了Mybatis plus 使用分页查询
service层中框架中自动实现的page方法
@Override
public IPage<BeanRole> loadPage(int page, int pageSize) {
Page<BeanRole> page1 = new Page<>(page, pageSize);
System.out.println(JSON.toJSONString(page1));
return page(page1);
}
最后定位到的错误是lombox的注解问题
@Data
@Builder
@TableName("role")
public class BeanRole {
@TableId(type = IdType.AUTO)
private int roleId;
private String roleName;
@TableField(exist = false)
private Set<BeanPermission> permissions;
}
由@Builder同时使用造成的异常
使用@Builder 而造成其生成了全参构造器,无参构造器不存在导致实例化异常