mybatis的分页插件能省事,本章记录的是 spring boot整合mybatis分页插件。

1、引入依赖

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

2、配置application.yml文件

注意 pagehelper 是一级根目录和 spring 同级

spring:
mvc:
view:
prefix: /
suffix: .jsp
datasource:
url: jdbc:mysql://localhost:3306/myrec?characterEncoding=utf8&useSSL=true
username: root
password: m123456
driver-class-name: com.mysql.jdbc.Driver #配置分页插件pagehelper
pagehelper:
helperDialect: mysql
reasonable: true
supportMethodsArguments: true
params: count=countSql

3、业务层使用

/**
* 按分页查询
*/
@Override
public PageResult findPage(int pageNum, int pageSize) {
PageHelper.startPage(pageNum, pageSize);
Page<Loginuser> page= (Page<Loginuser>) loginuserMapper.selectByExample(null);
return new PageResult(page.getTotal(), page.getResult());
}

包别导错了

import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;

spring boot集成mybatis分页插件的更多相关文章

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

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

  2. boot集成mybatis分页插件pagehelper

    导入依赖 <!-- https://mvnrepository.com/artifact/com.github.pagehelper/pagehelper-spring-boot-starter ...

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

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

  4. spring boot集成mybatis(2) - 使用pagehelper实现分页

    Spring Boot 集成教程 Spring Boot 介绍 Spring Boot 开发环境搭建(Eclipse) Spring Boot Hello World (restful接口)例子 sp ...

  5. spring boot集成mybatis(3) - mybatis generator 配置

    Spring Boot 集成教程 Spring Boot 介绍 Spring Boot 开发环境搭建(Eclipse) Spring Boot Hello World (restful接口)例子 sp ...

  6. spring boot 整合pagehelper分页插件

    Spring Boot 整合pagehelper分页插件 测试环境: spring boot  版本 2.0.0.M7 mybatis starter 版本  1.3.1 jdk 1.8 ------ ...

  7. Spring Boot集成MyBatis开发Web项目

    1.Maven构建Spring Boot 创建Maven Web工程,引入spring-boot-starter-parent依赖 <project xmlns="http://mav ...

  8. spring boot集成mybatis(1)

    Spring Boot 集成教程 Spring Boot 介绍 Spring Boot 开发环境搭建(Eclipse) Spring Boot Hello World (restful接口)例子 sp ...

  9. spring boot集成MyBatis 通用Mapper 使用总结

    spring boot集成MyBatis 通用Mapper 使用总结 2019年 参考资料: Spring boot集成 MyBatis 通用Mapper SpringBoot框架之通用mapper插 ...

随机推荐

  1. VMware15.5版本通过挂载系统光盘搭建yum仓库

    VMware15.5版本通过挂载系统光盘搭建yum仓库一.1.打开CentOS 7虚拟机. 2.登录虚拟机,选择未列出  用户名:root 密码:输入自己设置的密码 点击登录. 3.右键单击打开终端. ...

  2. python2+robotframework环境搭建

    目前robotframework-ride只支持python3,没办法,只能用python2.好吧 python安装不多说,太简单,下载后直接安装,然后配置两个文件路径:path:E:\mytest\ ...

  3. WPF MVVM之INotifyPropertyChanged接口的几种实现方式(转)

    原地址:https://www.cnblogs.com/xiwang/archive/2012/11/25/2787358.html 序言 借助WPF/Sliverlight强大的数据绑定功能,可以比 ...

  4. *P2398 GCD SUM[数论]

    题目描述 for i=1 to n for j=1 to n sum+=gcd(i,j) 解析 给出n求sum. gcd(x,y)表示x,y的最大公约数. 直接枚举复杂度为\(O(n^2)\),显然无 ...

  5. 【python】raise_for_status()抛出requests.HTTPError错误

    1.首先看下面代码的运行情况 import requests res = requests.get("https://www.csdn.net/eee", headers=head ...

  6. CORS 跨域 node |XMLHttpRequest 跨域提交数据 node

    node服务端 app.post('/getdata',function(req,res,next){ req.setEncoding('utf8'); res.setHeader('Access-C ...

  7. windows认证过程

    NTLM简介: NTLM使用在Windows NT和Windows 2000 Server(or later)工作组环境中(Kerberos用在域模式下).在AD域环境中,如果需要认证Windows ...

  8. [Web] About image: MozJPEG

    Image is quite heavy in web traffic. it is about 53% whole web traffic. It is important to make sure ...

  9. SpringCloud过滤filter

    目录 配置文件 application.yml eureka: client: service-url: defaultZone: http://localhost:8001/eureka serve ...

  10. Windbg命令脚本流程控制语句详解

    在Windbg命令脚本一文里,我们介绍了命令脚本语言的的组成要素,在本文里将对语句进行展开的讲解.这些语句主要是流程控制的语句,比如我们常见的条件分子和循环语句等. ; (命令分隔符) 分号(:)字符 ...