springboot pagehelper分页无效
springboot pagehelper分页无效
遇到的问题把所有的数据都查出来了
-然后跟踪代码发现PageHelper.startPage没有生效,生成的sql也没有分页的信息
- 依赖也引入了
<!-- https://mvnrepository.com/artifact/com.github.pagehelper/pagehelper -->
<dependency>
<groupId>com.github.pagehelper</groupId>
<artifactId>pagehelper</artifactId>
<version>5.1.8</version>
</dependency>
-然后开始各种搞PageHelper
- xml配置文件来一遍
<plugins>
<!-- com.github.pagehelper为PageHelper类所在包名 -->
<plugin interceptor="com.github.pagehelper.PageHelper">
<property name="dialect" value="mysql"/>
<!-- 该参数默认为false -->
<!-- 设置为true时,会将RowBounds第一个参数offset当成pageNum页码使用 -->
<!-- 和startPage中的pageNum效果一样-->
<property name="offsetAsPageNum" value="true"/>
<!-- 该参数默认为false -->
<!-- 设置为true时,使用RowBounds分页会进行count查询 -->
<property name="rowBoundsWithCount" value="true"/>
<!-- 设置为true时,如果pageSize=0或者RowBounds.limit = 0就会查询出全部的结果 -->
<!-- (相当于没有执行分页查询,但是返回结果仍然是Page类型)
<property name="pageSizeZero" value="true"/>-->
<!-- 3.3.0版本可用 - 分页参数合理化,默认false禁用 -->
<!-- 启用合理化时,如果pageNum<1会查询第一页,如果pageNum>pages会查询最后一页 -->
<!-- 禁用合理化时,如果pageNum<1或pageNum>pages会返回空数据 -->
<property name="reasonable" value="true"/>
<!-- 3.5.0版本可用 - 为了支持startPage(Object params)方法 -->
<!-- 增加了一个`params`参数来配置参数映射,用于从Map或ServletRequest中取值 -->
<!-- 可以配置pageNum,pageSize,count,pageSizeZero,reasonable,不配置映射的用默认值 -->
<!-- 不理解该含义的前提下,不要随便复制该配置
<property name="params" value="pageNum=start;pageSize=limit;"/> -->
</plugin>
</plugins>
- properties文件来一遍
#pagehelper分页插件配置
pagehelper.helperDialect=postgresql
pagehelper.reasonable=true
pagehelper.supportMethodsArguments=true
pagehelper.params=count=countSql
- 注解@bean来一遍
//配置mybatis的分页插件pageHelper
@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;
}
全都无效 其实只有一个目的就是生成PageHelper对象
最后starter来一下,操,就好了
<!-- https://mvnrepository.com/artifact/com.github.pagehelper/pagehelper-spring-boot-starter -->
<dependency>
<groupId>com.github.pagehelper</groupId>
<artifactId>pagehelper-spring-boot-starter</artifactId>
<version>1.2.10</version>
</dependency>
springboot pagehelper分页无效的更多相关文章
- SpringBoot+MyBatis+PageHelper分页无效
POM.XML中的配置如下:<!-- 分页插件 --><!-- https://mvnrepository.com/artifact/com.github.pagehelper/pa ...
- Springboot 系列(十二)使用 Mybatis 集成 pagehelper 分页插件和 mapper 插件
前言 在 Springboot 系列文章第十一篇里(使用 Mybatis(自动生成插件) 访问数据库),实验了 Springboot 结合 Mybatis 以及 Mybatis-generator 生 ...
- SpringBoot整合系列-PageHelper分页插件
原创作品,可以转载,但是请标注出处地址:https://www.cnblogs.com/V1haoge/p/9971043.html SpringBoot整合MyBatis分页插件PageHelper ...
- SpringBoot+Mybatis配置Pagehelper分页插件实现自动分页
SpringBoot+Mybatis配置Pagehelper分页插件实现自动分页 **SpringBoot+Mybatis使用Pagehelper分页插件自动分页,非常好用,不用在自己去计算和组装了. ...
- SpringBoot入门篇--整合mybatis+generator自动生成代码+druid连接池+PageHelper分页插件
原文链接 我们这一篇博客讲的是如何整合Springboot和Mybatis框架,然后使用generator自动生成mapper,pojo等文件.然后再使用阿里巴巴提供的开源连接池druid,这个连接池 ...
- 【spring boot】14.spring boot集成mybatis,注解方式OR映射文件方式AND pagehelper分页插件【Mybatis】pagehelper分页插件分页查询无效解决方法
spring boot集成mybatis,集成使用mybatis拖沓了好久,今天终于可以补起来了. 本篇源码中,同时使用了Spring data JPA 和 Mybatis两种方式. 在使用的过程中一 ...
- SpringBoot之分页插件PageHelper的使用
在springboot中使用PageHelper插件有两种较为相似的方式,接下来我就将这两种方式进行总结. 方式一:使用原生的PageHelper 1.在pom.xml中引入依赖 <depend ...
- 求助:springboot调用存储过程并使用了pagehelper分页时报错com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException
存储过程如下: dao层的sql Controller层调用: html页面 没有使用pagehelper分页之前,可以正常使用 使用了pagehelper之后就报错 ### Error queryi ...
- 小D课堂-SpringBoot 2.x微信支付在线教育网站项目实战_3-5.PageHelper分页插件使用
笔记 5.PageHelper分页插件使用 简介:讲解开源组件,mybaits分页插件的使用 1.引入依赖 <!-- 分页插件依赖 --> ...
随机推荐
- java.sql.SQLException: Data truncation: Incorrect string value: '\xE5\x91\xA8\xE6\x9D\xBE' for column 'cname' at row 1 Query
在将项目上传到服务器时,发生这样的错误,总结了一下. 环境Centos7+tomcat7+Mariadb数据库 首先mysql -uroot -p 输入密码 然后查询数据库当前码表状态 show va ...
- Centos7搭建Scrapy爬虫环境
写在前面 因为之前的爬虫环境一直是部署在我自己本地的电脑上的,最近,写了一个监控别人空间的爬虫,需要一直线上24小时运行,所有就打算云服务器上部署环境,也捣鼓了好一会才弄好,还是有一些坑,这里先记录一 ...
- 读《深入理解Elasticsearch》点滴-查询二次评分
理解二次评分 二次评分是指重新计算查询返回文档中指定个数文档的得分,es会截取查询返回的前N个,并使用预定义的二次评分方法来重新计算他们的得分 小结 有时候,我们需要显示查询结果,并且使得页面上靠前文 ...
- Spring MVC-从零开始-view-直接返回页面不传data
1.applicationContext配置 <?xml version="1.0" encoding="UTF-8"?> <beans xm ...
- java List转换和数组互转
1.List转Array ArrayList<String> list=new ArrayList<String>(); String[] strings = new Stri ...
- 极光推送消息——Alias别称方式(Andirod)
1.pom文件引入相关jar包 <!--极光推送消息start--> <dependency> <groupId>net.sf.json-lib</group ...
- Linux——基本命令
目录 一.目录切换命令 二.目录操作命令(增删改查) 2.1增加目录 2.2查看目录 2.3寻找目录(搜索) 2.4修改目录名称 2.5移动目录位置(剪切) 2.6拷贝目录 2.7删除目录 三.文件的 ...
- Python3 GUI开发(PyQt)安装和配置
Python3 GUI开发(PyQt5)安装和配置: 下载安装好Miniconda3, 并且安装好jupyter 注意:最好关闭360杀毒软件或者把cmd加入信任,否则运行activate会有问题. ...
- docker在Mac上的下载安装
在Mac上下载安装docker,下载链接:Stable 安装成功后启动终端,检查安装后的docker版本: yanguobindeMacBook-Pro:~ yanguobin$ docker --v ...
- 网络游戏开发-客户端2(自定义websocket协议格式)
Egret官方提供了一个Websocket的库,可以让我们方便的和服务器长连接交互. 标题写的时候自定义websocket的协议格式.解释一下,不是说我们去动websocket本身的东西,我们是在we ...