springboot pageHelper

 
 
导入依赖:

注意不要导入错依赖,不然,分页不生效,我项目是springboot,但是导入了其他项目的依赖,导致分页怎么都不生效,折腾了很久

springboot项目:

<dependency>
  <groupId>com.github.pagehelper</groupId>
  <artifactId>pagehelper-spring-boot-starter</artifactId>
  <version>1.2.3</version>
</dependency>

<!--其他项目-->
<!--<dependency>
  <groupId>com.github.pagehelper</groupId>
  <artifactId>pagehelper</artifactId>
  <version>${pagehelper}</version>
</dependency>-->
java代码:

页码设置一定要在查询语句上面,否则分页可能不生效

PageHelper.startPage(pageNum, pageSize);
List<Goods> list = goodsService.getList();
 
 
查询语句这样写
@Select("SELECT * FROM goods")
List<Goods> findBypage();

application.yml配置
pagehelper:
  helper-dialect: mysql
  reasonable: true
  support-methods-arguments: true
  params: count=countSql
加入以上配置就OK了

猜你喜欢

转载自blog.csdn.net/lianbancai/article/details/79839600
今日推荐