springboot+mybatis+gradle+PageHelper实现分页

用springboot+mybatis+gradle+PageHelper实现分页,记录一下!


第一步:

build.gradle引入配置文件:

dependencies {
    compile group: 'com.github.pagehelper', name: 'pagehelper-spring-boot-starter', version: '1.2.4'

}

第二步:

默认的情况这样就直接可以用了,但是如果不想用默认配置需要自定义配置的话,可以application.yml文件下面进行自定义配置;


如:

pagehelper:

        reasonable: false

第三步:

直接使用就可以了:

PageHelper.startPage(page,pagesize);//后面直接跟查询就可以了
List<ConfigServiceFile> configServiceFiles = fileMapper.page(configServiceFile);
注:默认的配置pagehelper.reasonable=true,这样导致的结果就是你查询的页数大于当前的也如的话,总会返回最后一页,如果想返回empty,可以在
application.yml配置文件中配置该属性为false;

猜你喜欢

转载自blog.csdn.net/chengkui1990/article/details/79931316