查出来的数据始终就是全部的,没有分页。 场景: 刚开始学MyBatis-Plus,使用了自带的分页插件,感觉查多表多条件分页不是很熟练,就想用原来使用的分页插件pagehelper,但是踩了一点小坑 配置的依赖如下: <dependency><groupId>com.github.pagehelper</groupId><artifactId>pagehelper</artifactId><version>5.1.11</ver...
pom.xml 中引入pageHelper依赖: (1)如果是 springboot,则可以直接引入 pagehelper-spring-boot-starter,它会帮我们省去许多不必要的配置。 <!-- https://mvnrepository.com/artifact/com.github.pagehelper/pagehelper-spring-boot-starter --> <dependency> <groupId>com.github.pagehelper</groupId> <artifactId>...
先说一下问题出现的原因:Mybatis和Mybatis-plus存在冲突,Pagehelper依赖于Mybatis,所以冲突了!! 解决方案:删Pagehelper和Mybatis的依赖,然后一点点的改若依一些基本配置的分页就好,最后在加上Mybatis-plus的分页插件配置!最最重要的是要扫描到写的分页插件,不然不生效! 二、删依赖 1、删除根目录的...
在MyBatis的配置文件(通常是mybatis-config.xml)中,需要配置PageHelper的插件。确保配置了正确的插件,并且插件的顺序正确。 <plugins> <plugin interceptor="com.github.pagehelper.PageInterceptor"> <property name="dialect" value="mysql"/> </plugin> </plugins> 复制代码 检查SQL语句是否正确。在进行分页查询时...
添加一个类,这个类用于初始化 PageInterceptor 这个类,这一次尝试成功,正确返回分页数据。代码如下: import com.baomidou.mybatisplus.extension.plugins.inner.PaginationInnerInterceptor; import com.github.pagehelper.PageInterceptor; import org.springframework.context.annotation.Bean; ...
PageHelper 的使用方式不对吧? hongchang.liu 王帅成员 3个月前 貌似是我项目数据源配置方式的问题 改成这种写法就可以了。 现在遇到了第二个个问题 图中registerInsertListener不起作用, 另外加了一个实现MyBatisFlexCustomizer的配置类同样也不生效 hongchang.liu ...
改成 <!-- 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.5</version></dependency>...
当然是可以的了,但是有个MyBatis的插件PageHelper在做分页时是非常好用的。可是在插件PageHelper实际使用的时候却偶尔会发生一个问题,一个小坑。那就是一个本来没有做分页的查询,通过输出日志可以看到,在执行查询的时候却用了分页。导致查询不到数据,或是查询到错误的数据。为了解决这个问题,我们来大致看下插件...
使用了Spring的PageHelper插件,发现了一个奇怪的问题,经常会给SQL无缘无故的增加Limit语句,经过调查,发现原因是没有安全的使用PageHelper插件 1. 然后给出的解决方案就是: 要绝对保证PageHelper.startPage和分页查询语句之间不要有任何其他语句,或者在程序结束时增加PageHelper.clearPage();的调用 ...