Spring Boot 整合pagehelper分页插件

测试环境:

spring boot  版本 2.0.0.M7

mybatis starter 版本  1.3.1

jdk 1.8

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

1.  maven  引入 pagehelper 相关Jar包

        <!-- 分页插件pagehelper -->
<dependency>
<groupId>com.github.pagehelper</groupId>
<artifactId>pagehelper</artifactId>
<version>5.0.0</version>
</dependency>
<dependency>
<groupId>com.github.pagehelper</groupId>
<artifactId>pagehelper-spring-boot-autoconfigure</artifactId>
<version>1.2.3</version>
</dependency>
<dependency>
<groupId>com.github.pagehelper</groupId>
<artifactId>pagehelper-spring-boot-starter</artifactId>
<version>1.2.3</version>
</dependency>
<!-- 分页插件pagehelper -->

2.  Service层代码 只需添加一句核心分页代码  (要在dao调用之前)

参数page为当前页码 、pagesize为每页显示多少条记录

    public List<UserEntity> usersList(String loginName, int pageSize, int page) {
PageHelper.startPage(page,pageSize);
return userDao.usersList();
}

3.  Controller层代码   用pagehelper封装的 PageInfo类封装返回查询的list结果 如下图红色字体

    @GetMapping("/users")
public PageInfo<UserEntity> usersList(String loginName, int pageSize, int page) { List<UserEntity> list = userService.usersList(loginName,pageSize,page);
PageInfo<UserEntity> pageinfo = new PageInfo<UserEntity>(list);
log.debug("The method is ending");
return pageinfo;
}

下断点调试后  显示 pageinfo的结果为

各项信息都已经显示出来  分页插件加载成功!

spring boot 整合pagehelper分页插件的更多相关文章

  1. spring boot集成mybatis分页插件

    mybatis的分页插件能省事,本章记录的是 spring boot整合mybatis分页插件. 1.引入依赖 <!-- 分页插件pagehelper --> <dependency ...

  2. Spring Boot实践——Mybatis分页插件PageHelper的使用

    出自:https://blog.csdn.net/csdn_huzeliang/article/details/79350425 在springboot中使用PageHelper插件有两种较为相似的方 ...

  3. Spring Boot+Mybatis+Pagehelper分页

    Spring Boot 集成MyBatis和Pagehelper分页插件 mybatis-spring-boot-starter依赖树如下: pom配置 <project xmlns=" ...

  4. SpringBoot集成整合pageHelper分页插件

    今天来讲讲springboot 集成 pagehelper插件, 引入jar 依赖包 <!-- 分页插件 --><dependency> <groupId>com. ...

  5. Spring Boot整合tk.mybatis及pageHelper分页插件及mybatis逆向工程

    Spring Boot整合druid数据源 1)引入依赖 <dependency> <groupId>com.alibaba</groupId> <artif ...

  6. 【spring boot】14.spring boot集成mybatis,注解方式OR映射文件方式AND pagehelper分页插件【Mybatis】pagehelper分页插件分页查询无效解决方法

    spring boot集成mybatis,集成使用mybatis拖沓了好久,今天终于可以补起来了. 本篇源码中,同时使用了Spring data JPA 和 Mybatis两种方式. 在使用的过程中一 ...

  7. spring boot 整合mybatis 的xml版本【包括逆向工程以及分页插件】

    逆向工程很方便,可以直接根据数据库和配置文件生成pojo,mapper接口和相应的映射文件. xml版本和全注解版本其实差不多,大部分情况下,都会保留xml文件方便其他人去扩展新的dml方法. 文章旨 ...

  8. SpringBoot入门篇--整合mybatis+generator自动生成代码+druid连接池+PageHelper分页插件

    原文链接 我们这一篇博客讲的是如何整合Springboot和Mybatis框架,然后使用generator自动生成mapper,pojo等文件.然后再使用阿里巴巴提供的开源连接池druid,这个连接池 ...

  9. SpringBoot整合系列-PageHelper分页插件

    原创作品,可以转载,但是请标注出处地址:https://www.cnblogs.com/V1haoge/p/9971043.html SpringBoot整合MyBatis分页插件PageHelper ...

随机推荐

  1. 设置Redis最大占用内存

    https://blog.csdn.net/happyrabbit456/article/details/54945667 Redis需要设置最大占用内存吗?如果Redis内存使用超出了设置的最大值会 ...

  2. MySQL 的日期类型有5个,分别是: date、time、year、datetime、timestamp。

    类型 字节 格式 用途 是否支持设置系统默认值 date 3 YYYY-MM-DD 日期值 不支持 time 3 HH:MM:SS 时间值或持续时间 不支持 year 1 YYYY 年份 不支持 da ...

  3. Ionic 使用karma进行单元测试

    1. 创建Ionic工程 ionic start projectname cd projectname 2.安装karma插件 npm install karma karma-jasmine karm ...

  4. ubuntu16 配置git

    github上的开源项目,在ubuntu系统中无法进行clone,通过在网站上注册账户,用命令生成ssh 公钥和私钥,把公钥添加到网站账户中可解决这个问题 1.产生ssh key ssh-keygen ...

  5. ML: 聚类算法R包-层次聚类

    层次聚类 stats::hclust stats::dist    R使用dist()函数来计算距离,Usage: dist(x, method = "euclidean", di ...

  6. 源代码安装Apache、Mysql、PHP

    源代码软件的优点:     获得最新版,能及时修复bug:     能自行修改和定制: 源代码打包形式:     .tar.gz和.tar.bz2格式居多: 完整性校验:     md5sum校验工具 ...

  7. 跟着未名学Office – 整体了解 Ms Office 2010

    目录 MS Office 2010    2 Microsoft Office System    2 Ribbon(功能区)    2 文件选项卡    3 SmartArt    3 屏幕截图   ...

  8. 机器学习笔记——t分布知识点总结

    (原创文章,转载请注明地址:http://www.cnblogs.com/wangkundentisy/p/6539058.html ) 1.t分布式统计分布的一种,同卡方分布(χ2分布).F分布并称 ...

  9. 《Java并发编程实战》笔记-synchronized和ReentrantLock

    在一些内置锁无法满足需求的情况下,ReentrantLock可以作为一种高级工具.当震要一些高级功能时才应该使用ReentrantLock,这些功能包括:可定时的.可轮询的与可中断的锁获取操作,公平队 ...

  10. Java学习——多线程例子:李四王五

    package cys; public class Example9_2 { public static void main(String[] args) { // TODO Auto-generat ...