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. pri 知识点

    pri github:https://github.com/prijs/pri 添加路由后动态导入,使用的是 react-loadable:https://github.com/jamiebuilds ...

  2. js判斷是否是正整數

    var curt_page = $("input[name='curt_page']").val(); if (!(/(^[1-9]\d*$)/.test(curt_page))) ...

  3. py-day1-2 python的循环语句

    死循环: 条件循环: 练习 第一题: n = 1 while n < 11: if n == 7: pass else: print(n) n = n + 1 print('-----end-- ...

  4. Hbase 简介+环境安装配置教程

    HBase介绍 HBase是参考google的bigtable的一个开源产品,建立在hdfs之上的一个提供高可靠性.高性能.列存储.可伸缩.实时读写的数据库系统.是一种介于nosql和RDBMs之间的 ...

  5. 阿里巴巴Java编码规范,来测测你能得多少分

    今年年初,<阿里巴巴Java开发手册>正式发布,阿里官方Java代码规范标准首次对外公开.手册发布之后在业界.学术界都获得了广泛的关注,仅微博浏览量就突破千万,下载访问量超过40万,多家媒 ...

  6. paramiko 实现ssh登录和sftp登录

    简单ssh登录 import paramiko ssh = paramiko.SSHClient() ssh.set_missing_host_key_policy(paramiko.AutoAddP ...

  7. Windows Azure Web Site (18) Azure Web App设置MIME

    <Windows Azure Platform 系列文章目录> 在笔者之前的文章中,介绍了我们在使用Azure Web App,可以把静态资源保存到Azure Storage中: Wind ...

  8. url参数的转码和解码

    encodeURI(str) //转码 decodeURI(str)//解码

  9. mac下面 ,启动2个桌面版appium的方法

    分别打开2个终端,分别输入 appium 就可以分别起2个appium桌面版,然后设置端口 即可 参考: https://blog.csdn.net/qq_15283475/article/detai ...

  10. Spring Boot下Druid连接池+mybatis

      目前Spring Boot中默认支持的连接池有dbcp,dbcp2, hikari三种连接池.  引言: 在Spring Boot下默认提供了若干种可用的连接池,Druid来自于阿里系的一个开源连 ...