mybatis plus分页插件PageHelper用法
·
一、引入 pagehelper 依赖
<!-- PageHelper 分页插件 -->
<dependency>
<groupId>com.github.pagehelper</groupId>
<artifactId>pagehelper-spring-boot-starter</artifactId>
<version>1.2.5</version>
<exclusions>
<exclusion>
<groupId>org.mybatis</groupId>
<artifactId>mybatis</artifactId>
</exclusion>
<exclusion>
<groupId>mybatis-spring</groupId>
<artifactId>org.mybatis</artifactId>
</exclusion>
</exclusions>
</dependency>
二、在 yml 配置文件中配置如下信息即可使用分页插件:
#分页设置
pagehelper:
helperDialect: mysql
reasonable: true
supportMethodsArguments: true
pageSizeZero: false #pageSize=0 返回所有
params: count=countSql
三、使用 pagehelper 进行分页查询
核心代码:
PageHelper.startPage(pageNum,pageSize);
PageInfo<PurchasePlan> pageInfoRes = new PageInfo<>(purchasePlanService.list());
魔乐社区(Modelers.cn) 是一个中立、公益的人工智能社区,提供人工智能工具、模型、数据的托管、展示与应用协同服务,为人工智能开发及爱好者搭建开放的学习交流平台。社区通过理事会方式运作,由全产业链共同建设、共同运营、共同享有,推动国产AI生态繁荣发展。
更多推荐


所有评论(0)