springboot + pagehelper實現分頁

1-在pom.xml中引入依賴

自己可以去maven使用最新版本
<!-- https://mvnrepository.com/artifact/com.github.pagehelper/pagehelper-spring-boot-starter -->
        <dependency>
            <groupId>com.github.pagehelper</groupId>
            <artifactId>pagehelper-spring-boot-starter</artifactId>
            <version>1.2.13</version>
        </dependency>

2.在application.yml中做如下配置

# 分頁配置
pagehelper:
  helper-dialect: mysql
  reasonable: true
  support-methods-arguments: true
  params: count=countSql

3.在代碼中使用

 PageHelper.startPage(10, 30);
 List<Map<String, Object>> list= mapper.infoList(params);
 PageInfo pageInfo = new PageInfo(list);

4.最後返回的PageInfo信息
在這裏插入圖片描述

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章