1.pom.xml中引入jar包
<dependency>
<groupId>com.github.pagehelper</groupId>
<artifactId>pagehelper-spring-boot-starter</artifactId>
<version>1.2.7</version>
</dependency>
2.service中應用
只要添加以下這句就可以了,此方法後的第一個查詢將執行分頁操作,參數分別是當前頁和每頁要顯示的記錄數量
PageHelper.startPage(1, 2);
如圖:
效果: