关于springboot整合配置pagehelper插件的方法
一,java代码配置法
这种方法个人感觉比较繁琐不是很推荐,而且也不怎么符合springboot的理念,但是胜在也能够用,所以就列起来,万一以后接手的代码是用这种方式的也方便自己维护。
首先引入jar包。
<dependency>
<groupId>com.github.pagehelper</groupId>
<artifactId>pagehelper</artifactId>
<version>4.1.6</version>
</dependency>
然后,直接在启动类里面添加如下代码:

@Bean
public PageHelper pageHelper(){
PageHelper pageHelper = new PageHelper();
Properties properties = new Properties();
properties.setProperty("offsetAsPageNum","true");
properties.setProperty("rowBoundsWithCount","true");
properties.setProperty("reasonable","true");
properties.setProperty("dialect","mysql"); //配置mysql数据库的方言
pageHelper.setProperties(properties);
return pageHelper;
}

那么这样第一种办法就配置好了。
二、配置文件配置法
第二种方法就比较简单了,而且从引入jar包的名字就能看出官方推荐的是哪种配置方式了。
<dependency>
<groupId>com.github.pagehelper</groupId>
<artifactId>pagehelper-spring-boot-starter</artifactId>
<version>1.1.0</version>
</dependency>
引入jar包后只要在application.properties或者application.yml里面加入相关的属性配置就好了,由于个人不太喜欢yml的形式,所以就只列一下application.properties的配置。

# pagehelper properties
pagehelper.offsetAsPageNum=true
pagehelper.rowBoundsWithCount=true
pagehelper.pageSizeZero=true
pagehelper.reasonable=false
pagehelper.params=pageNum=pageHelperStart;pageSize=pageHelperRows;
pagehelper.supportMethodsArguments=false

而且似乎pagehelper不需要配置dialect这个属性也能正常工作。
关于springboot整合配置pagehelper插件的方法的更多相关文章
- SpringBoot整合系列-PageHelper分页插件
原创作品,可以转载,但是请标注出处地址:https://www.cnblogs.com/V1haoge/p/9971043.html SpringBoot整合MyBatis分页插件PageHelper ...
- SpringBoot+Mybatis配置Pagehelper分页插件实现自动分页
SpringBoot+Mybatis配置Pagehelper分页插件实现自动分页 **SpringBoot+Mybatis使用Pagehelper分页插件自动分页,非常好用,不用在自己去计算和组装了. ...
- springboot整合mybatis+pageHelper
springboot整合mybatis+pageHelper 〇.搭建sporingboot环境,已经整合mybatis环境,本篇主要是添加pageHelper工具 一.添加依赖 <!-- 分页 ...
- jackson学习之十(终篇):springboot整合(配置类)
欢迎访问我的GitHub https://github.com/zq2599/blog_demos 内容:所有原创文章分类汇总及配套源码,涉及Java.Docker.Kubernetes.DevOPS ...
- springboot + mybatis配置分页插件
一:使用pagehelper配置分页插件 1:首先配置springboot +mybatis框架 参考:http://www.cnblogs.com/liyafei/p/7911549.html 2 ...
- 在项目中配置PageHelper插件时遇到类型转换异常
PageHelper是一种常用的分页工具,按照常规方法在mybatis的配置文件中整合它: <?xml version="1.0" encoding="UTF-8& ...
- SpringBoot 整合Mybatis + PageHelper 实现分页
前言: 现在公司大多数都实现了前后端分离,前端使用Vue.React.AngularJS 等框架,不用完全依赖后端.但是如果对于比较小型的项目,没必要前后端分离,而SpringBoot也基本抛弃了Js ...
- springboot整合mybatis分页插件PageHelper
1 pom文件引入依赖 (注意:pagehelper版本不能太高,楼主之前用的5.0以上的版本,然后分页没有效果,浪费了两个小时才发现这个原因) <!-- mybatis的分页插件 --> ...
- SpringBoot中Mybaties PageHelper插件使用
首先引入pom.xml文件配置 <!-- mybatis --> <dependency> <groupId>org.mybatis.spring.boot&l ...
随机推荐
- linux(ubuntu) python 版本切换
参考链接:https://blog.csdn.net/thankyou0/article/details/79610854
- Solr 7.7.0 部署到Tomcat
第一步 1.Solr 解压后server/solr-webapp下一个webapp目录,它就是Solr的Web项目,把它复制到tomcat的webapps目录下并改名为solr # 进入Solr的se ...
- nginx 目录讲解
- laravel 关闭 csrf 验证 TokenMismatchException
csrf验证失败 注释掉kernel.php 的 csrf 行代码
- 【转】python 历险记(四)— python 中常用的 json 操作
[转]python 历险记(四)— python 中常用的 json 操作 目录 引言 基础知识 什么是 JSON? JSON 的语法 JSON 对象有哪些特点? JSON 数组有哪些特点? 什么是编 ...
- 使用cstdiofile在vs2010中无法写入中文的问题
在VC2010环境下, 以下代码无法实现使用CStdioFile向文本文件中写入中文(用notepad.exe查看不到写入的中文) CStdioFile file; file.Open(…); fil ...
- VC操作excel
http://www.cnblogs.com/witxjp/archive/2010/06/05/1752181.html 最近在做个数据库程序,因为有些数据用户要求导出到Excel文件显示(需要 ...
- Java的if判断对象为null时,null放在比较运算符的左边还是右边较好?
如java中:if(name == null)和if(null == name)有什么讲究吗? 答:在java里面,它们是一样的.但是通常写为null == name.这其实是在C语言里面引申出来的. ...
- 范围for语句
C++11 新标准引入了一种更简单的for语句,这种语句可以遍历容器或其他序列的所有元素.范围for语句(range for statement)的语法形式是: for (declaration : ...
- ansible笔记(11):初识ansible playbook(二)
ansible笔记():初识ansible playbook(二) 有前文作为基础,如下示例是非常容易理解的: --- - hosts: test211 remote_user: root tasks ...