pagehelper.getList查询出了全部的数据,并不是limit的数据

先说原因:遇到pagehelper的错误,很多是版本的原因

具体场景:

前提条件是:从第1页开始,每页10个,总数据是100个。

那么总页数就是10,所以getList的条数应该是10个,但是却是100个。

-----------------------------------

application.yml中的配置

pagehelper:
  helperDialect: mysql
  reasonable: true
  supportMethodsArguments: true
  params: count=countSql

serviceImpl中代码:

PageHelper.startPage(offset, limit);
List<Ztry> list = ztryMapper.queryZtryPageList(paramsMap);
PageInfo<Ztry> page = new PageInfo<Ztry>(list);
	

pom.xml中,因为开始是如下引用的。

<dependency>
	<groupId>com.github.pagehelper</groupId>
	<artifactId>pagehelper</artifactId>
	<version>5.1.2</version>
</dependency>

所以这里把jar包改成下面的形式就可以了。

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

让springboot自己去引入pagehelper的各种依赖包,就不会因为不兼容而导致莫名其妙的错误。

结果如图:


版权声明:本文为u012138706原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接和本声明。