spring boot 整合pagehelper分页插件
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分页插件的更多相关文章
- spring boot集成mybatis分页插件
mybatis的分页插件能省事,本章记录的是 spring boot整合mybatis分页插件. 1.引入依赖 <!-- 分页插件pagehelper --> <dependency ...
- Spring Boot实践——Mybatis分页插件PageHelper的使用
出自:https://blog.csdn.net/csdn_huzeliang/article/details/79350425 在springboot中使用PageHelper插件有两种较为相似的方 ...
- Spring Boot+Mybatis+Pagehelper分页
Spring Boot 集成MyBatis和Pagehelper分页插件 mybatis-spring-boot-starter依赖树如下: pom配置 <project xmlns=" ...
- SpringBoot集成整合pageHelper分页插件
今天来讲讲springboot 集成 pagehelper插件, 引入jar 依赖包 <!-- 分页插件 --><dependency> <groupId>com. ...
- Spring Boot整合tk.mybatis及pageHelper分页插件及mybatis逆向工程
Spring Boot整合druid数据源 1)引入依赖 <dependency> <groupId>com.alibaba</groupId> <artif ...
- 【spring boot】14.spring boot集成mybatis,注解方式OR映射文件方式AND pagehelper分页插件【Mybatis】pagehelper分页插件分页查询无效解决方法
spring boot集成mybatis,集成使用mybatis拖沓了好久,今天终于可以补起来了. 本篇源码中,同时使用了Spring data JPA 和 Mybatis两种方式. 在使用的过程中一 ...
- spring boot 整合mybatis 的xml版本【包括逆向工程以及分页插件】
逆向工程很方便,可以直接根据数据库和配置文件生成pojo,mapper接口和相应的映射文件. xml版本和全注解版本其实差不多,大部分情况下,都会保留xml文件方便其他人去扩展新的dml方法. 文章旨 ...
- SpringBoot入门篇--整合mybatis+generator自动生成代码+druid连接池+PageHelper分页插件
原文链接 我们这一篇博客讲的是如何整合Springboot和Mybatis框架,然后使用generator自动生成mapper,pojo等文件.然后再使用阿里巴巴提供的开源连接池druid,这个连接池 ...
- SpringBoot整合系列-PageHelper分页插件
原创作品,可以转载,但是请标注出处地址:https://www.cnblogs.com/V1haoge/p/9971043.html SpringBoot整合MyBatis分页插件PageHelper ...
随机推荐
- k8s 的使用
Kubernetes 是什么:在 Docker 技术的基础上,为容器化的应用提供部署运行.资源调度.服务发现和动态伸缩等一系列完整功能,提高了大规模容器集群管理的便捷性的工具.
- bind智能DNS + bindUI管理系统
bind UI 管理系统 https://github.com/cucker0/BindUI # bind安装 cd /usr/local/src wget http://ftp.isc.org/is ...
- 深入解析 ext2 文件系统 (转)
http://blog.chinaunix.net/uid-24774106-id-3266816.html 很久以来,就想写一篇关于ext 家族文件系统的文章,源于我刚工作的时候,曾经一不小心rm ...
- 【转】EF Code First 学习笔记:约定配置
要更改EF中的默认配置有两个方法,一个是用Data Annotations(在命名空间System.ComponentModel.DataAnnotations;),直接作用于类的属性上面;还有一个就 ...
- Golang如何使用websocket
下载websocket包 $ go get golang.org/x/net/websocket 如果下载失败,可能是被墙了. package golang.org/x/net/websocket: ...
- Java消息机制 ActiveMQ入门实例
转载自:http://www.cnblogs.com/wyh3721/p/5917316.html 1.下载ActiveMQ 去官方网站下载:http://activemq.apache.org/ ...
- sql日期操作
日期格式化函数 ), ): :57AM ), ): ), ): ), ): ), ): ), ): ), ): ), ): , ), ): :: ), ): :::827AM ), ): ), ): ...
- Django REST framework 源码剖析
前言 Django REST framework is a powerful and flexible toolkit for building Web APIs. 本文由浅入深的引入Django R ...
- 跟着未名学Office - 熟练使用WORD
目录 第一章.Word之编辑篇. 1 第一节 页面布局... 1 第二节 格式编辑... 1 第三节 表.图.域... 5 第四节 审阅.保护... 7 第五节 *插入对像... 9 第二章.Word ...
- vue img标签图片加载时 闪烁
//jsdata(){ return{ img_url: '', } },created(){ //请求数据,并给图片赋值url ajax.get(http_url) .then(res=>{ ...