美文网首页
mybatis plus分页插件PageHelper用法

mybatis plus分页插件PageHelper用法

作者: 拄杖忙学轻声码 | 来源:发表于2021-09-02 13:46 被阅读0次

一、引入 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());

相关文章

网友评论

      本文标题:mybatis plus分页插件PageHelper用法

      本文链接:https://www.haomeiwen.com/subject/otiziltx.html