首先網上很多文章分頁都是不生效,所以我才總結一下。
1、在pom.xml中添加
<dependency>
<groupId>com.github.pagehelper</groupId>
<artifactId>pagehelper</artifactId>
<version>4.1.4</version>
</dependency>
2、在application.properties文件或者application.yml文件中,也就是springboot初始化加載的配置文件信息
pagehelper.helper-dialect=mysql // 根據自己使用的數據庫進行設置
pagehelper.params=count=countSql
#pagehelper.reasonable=false // 這行必須註釋掉,要不分頁不生效
pagehelper.support-methods-arguments=true
3、在service層或者dao層添加PageHelper
Page<SysMcnMenu> pageInfo = PageHelper.startPage(2, 10);
List<SysMcnMenu> list6 =sysMcnMenu.selectAll(null);
總結,親測可用,不需要任何其他的包引入,如果有任何問題可以隨時提問,或者說的不對的地方也可以提出,謝謝大家賞識,qq350363705,如需轉載望附上博主的鏈接