springboot 集成分页组件PageHelper

1.依赖引入

	<dependency>
			<groupId>com.github.pagehelper</groupId>
			<artifactId>pagehelper-spring-boot-starter</artifactId>
			<version>RELEASE</version>
	</dependency>

2.application.properties配置

pagehelper.helperDialect=mysql
pagehelper.reasonable=true
pagehelper.supportMethodsArguments=true
pagehelper.params=count=countSql

3.使用

    //分页
    PageHelper.startPage(1,2);
    Example example = new Example(Person.class);
    Example.Criteria criteria = example.createCriteria();
    criteria.andEqualTo("userName","1");
    List<Person> people = personMapper.selectByExample(example);

4.属性:reasonable相关
问题:当数据库中有少量数据时,取分页页码较大时也能取到数据
数据库中有三条数据
springboot 集成分页组件PageHelper

分页取较大页数的数据时,依然能取到数据,预期是取不到数据,与预期有差
springboot 集成分页组件PageHelper
原因:pagehelper.reasonable=true,当设置为true时自带分页参数合理话,
修改为pagehelper.reasonable=false
springboot 集成分页组件PageHelper
符合预期。
3.3.0以上版本可用,默认是false.