现象:共计15条数据,分页参数传之后,查询,仍返回15条。
原因1:如果你是是引用以下依赖:
com.github.pagehelper pagehelper5.1.8
那么需要修改为:
com.github.pagehelper pagehelper-spring-boot-starter1.2.10
yml添加:
#pagehelper分页插件配置 pagehelper: helperDialect: mysql reasonable: true supportMethodsArguments: true params: count=countSql
然后可能还是报错。
原因2:依赖冲突
所以排除相关包,即:
com.github.pagehelper pagehelper-spring-boot-starter1.2.10 org.mybatis mybatisorg.mybatis mybatis-springorg.apache.logging.log4j log4j-slf4j-implslf4j-api org.slf4j logback-classic ch.qos.logback log4j-over-slf4j org.slf4j jul-to-slf4j org.slf4j spring-boot-starter-logging org.springframework.boot
获取数据:
@GetMapping("findByAllwithPage")
public PageInfo findByAllwithPage(int page, int pageSize, xx xx) {
PageHelper.startPage(page, pageSize);
return new PageInfo<>(xx.findByAll(xx));
}



