springboot2 pagehelper 使用笔记
作者:cnJun
博客专栏:
https://www.cnblogs.com/cnJun/
pom.xml
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.0.4.RELEASE</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>
<dependency>
<groupId>com.github.pagehelper</groupId>
<artifactId>pagehelper-spring-boot-starter</artifactId>
<version>1.2.5</version>
</dependency>
引入的jar包必须是要pagehelper-spring-boot-starter
如果单独引入pagehelper
的话,分页会不成功,现在导入的结果如下:
使用时PageHelper.startPage(pageNum, pageSize)一定要放在列表查询上面,这样在查询时会查出相应的数据量且会查询出总数,像图中总数量有两条,page里面查询出来了是2,但list只查出了1条,因为我传的分页是pageNo=1,pageSize=1
PageHelper.startPage(pageNum, pageSize);
List<SystemUserPageVo> systemUserList = systemUserMapper.page(find);
PageInfo<SystemUserPageVo> page = new PageInfo<>(systemUserList);
打印的sql如下所示
Preparing: SELECT count(0) FROM (SELECT su.id, su.name, su.nick_name, su.email, su.phone, su.sex, su.fail_num, su.status, su.create_time, su.update_time, GROUP_CONCAT(sr.name) AS rolesName FROM SYSTEM_USER su, system_user_role sur, system_role sr WHERE su.id = sur.user_id AND sur.role_id = sr.id GROUP BY su.id) table_count
Parameters:
Total: 1
Preparing: SELECT su.id, su.name, su.nick_name, su.email, su.phone, su.sex, su.fail_num, su.status, su.create_time, su.update_time, group_concat(sr.name) as rolesName FROM SYSTEM_USER su, system_user_role sur, system_role sr WHERE su.id = sur.user_id AND sur.role_id = sr.id GROUP BY su.id LIMIT ?
Parameters: 1(Integer)
Total: 1
springboot2 pagehelper 使用笔记的更多相关文章
- spring-boot-2.0.3源码篇 - pageHelper分页,绝对有值得你看的地方
前言 开心一刻 说实话,作为一个宅男,每次被淘宝上的雄性店主追着喊亲,亲,亲,这感觉真是恶心透顶,好像被强吻一样.........更烦的是我每次为了省钱,还得用个女号,跟那些店主说:“哥哥包邮嘛么叽. ...
- SpringBoot2.0+Mybatis+PageHelper+Redis实现缓存
1.在maven引入相关的依赖 <parent> <groupId>org.springframework.boot</groupId> <artifactI ...
- springboot2集成pagehelper
springboot2集成pagehelper超级简单,本示例直接抄袭官方示例,仅将数据库由H2改成MySQL而已. 1. pom.xml <?xml version="1.0&quo ...
- SpringBoot2.0之五 优雅整合SpringBoot2.0+MyBatis+druid+PageHelper
上篇文章我们介绍了SpringBoot和MyBatis的整合,可以说非常简单快捷的就搭建了一个web项目,但是在一个真正的企业级项目中,可能我们还需要更多的更加完善的框架才能开始真正的开发,比如连接池 ...
- springboot集成PageHelper,支持springboot2.0以上版本
第一步:pom文件还是需要引入依赖 <!--mybatis的分页插件--> <dependency> <groupId>com.github.pagehelper& ...
- springboot2.0 使用aop实现PageHelper分页
参考: https://blog.csdn.net/qq_24076135/article/details/85212081 https://www.jianshu.com/p/036d31ae77d ...
- springboot学习笔记:8. springboot+druid+mysql+mybatis+通用mapper+pagehelper+mybatis-generator+freemarker+layui
前言: 开发环境:IDEA+jdk1.8+windows10 目标:使用springboot整合druid数据源+mysql+mybatis+通用mapper插件+pagehelper插件+mybat ...
- Activiti工作流框架学习笔记(二)之springboot2.0整合工作流Activiti6.0
以前在工作当中做过不少与工作流Activiti有关的工作,当时都是spring集成activiti5.22的项目,现在回过头去看,其实版本已经稍微老了,因此,基于先前的工作经验,决定用较新版本的技术来 ...
- springboot2.1.3.RELEASE+jsp笔记war部署tomcat
springboot+jsp <packaging>war</packaging> <parent> <groupId>org.springframew ...
随机推荐
- Python基础——7面向对象高级编程
实例与类动态添加方法 实例添加属性: def Student(object): pass s = Student() s.name = ‘syz’ 实例添加方法 from types import M ...
- JetBrains 注册码
C40PF37RR0-eyJsaWNlbnNlSWQiOiJDNDBQRjM3UlIwIiwibGljZW5zZWVOYW1lIjoiemhhbmcgeW9uZyIsImFzc2lnbmVlTmFtZ ...
- qemu 系列
一.. qemu uboot 1. 首先安装交叉编译器,执行: sudo apt-get install gcc-arm-linux-gnueabi 2. 下载U-Boot源文件: ht ...
- vue 路由变化页面数据不刷新问题(缓存)
每天记录一点点,把我遇到的问题记录下来, 希望可以帮助到更多和我遇到同样问题的人. 问题描述:通过调接口,动态显示帮助页面的问题列表, 问题列表有多级,当点击的这个问题没有下一级问题的时候跳入内容页. ...
- mybatis中大于等于小于的写法
第一种写法(1): 原符号 < <= > >= & ' "替换符号 < <= > >= & ' " ...
- SpringMVC处理请求和返回流程
流程描述:一个url请求,找打指定的requestMapping再返回指定的jsp界面 通过url拿到指定的java方法 HandlerExecutionChain mappedHandler = ...
- Linux内核入门到放弃-设备驱动程序-《深入Linux内核架构》笔记
I/O体系结构 总线系统 PCI(Peripheral Component Interconnect) ISA(Industrial Standard Architecture) SBus IEEE1 ...
- Python排序算法——冒泡排序
有趣的事,Python永远不会缺席! 如需转发,请注明出处:小婷儿的python https://www.cnblogs.com/xxtalhr/p/10786904.html 一.冒泡排序(Bubb ...
- 【原创】架构师必备,带你弄清混乱的JAVA日志体系!
引言 还在为弄不清commons-logging-xx.jar.log4j-xx.jar.sl4j-api-xx.jar等日志框架之间复杂的关系而感到烦恼吗? 还在为如何统一系统的日志输出而感到不知所 ...
- Quick Sort(Java)
public static void main(String[] args) { Scanner input = new Scanner(System.in); int n = input.nextI ...