springboot3无法使用pagehelper分页插件问题;pagehelper分页失效;

先说自身springboot框架版本:springboot3.0.0

最终解决方案:更新pagehelper启动器版本为1.4.6

 在学习springboot3集成mybatis时发现使用pagehelper.starter(num,size,sort)时,无法进行分页操作。

 首先去看了下官网的普遍问题。↓ ↓↓↓↓↓↓↓↓↓ ↓以下来自pagehelper官网(链接)。

发现问题都对应不上后,开始考虑版本问题。

最开始使用的依赖版本为1.4.1(如下):

<dependency>
    <groupId>com.github.pagehelper</groupId>
    <artifactId>pagehelper-spring-boot-starter</artifactId>
    <version>1.4.1</version>
</dependency>
查看mavenrepository(链接)发现诸多人在1.4.1的后继1.4.*版本中选择1.4.6(图省事也没去查github对应pagehelper更新日志)

于是切换版本进行尝试

<dependency>
    <groupId>com.github.pagehelper</groupId>
    <artifactId>pagehelper-spring-boot-starter</artifactId>
    <version>1.4.6</version>
</dependency>

 问题解除。

  • 9
    点赞
  • 11
    收藏
    觉得还不错? 一键收藏
  • 2
    评论
Spring Boot项目中集成PageHelper分页插件的步骤如下: 1. 打开Maven库,找到com.github.pagehelper:pagehelper-spring-boot-starter。 2. 确定需要使用的版本号,比如1.4.1。 3. 在项目的pom.xml文件中添加PageHelper的依赖。可以使用如下代码: ``` <dependency> <groupId>com.github.pagehelper</groupId> <artifactId>pagehelper-spring-boot-starter</artifactId> <version>1.4.1</version> </dependency> ``` 4. 在application.properties或application.yml配置文件中进行配置,添加以下属性: ``` # 开启分页支持 pagehelper.helper-dialect=mysql pagehelper.reasonable=true pagehelper.support-methods-arguments=true pagehelper.params=count=countSql ``` 这里的配置是针对MySQL数据库的,如果你使用的是其他数据库,需要根据对应的数据库类型进行配置。 5. 在需要分页的Mapper方法上使用PageHelper.startPage方法来开启分页功能。例如: ``` @Mapper public interface UserMapper { List<User> getUsers(); } ``` 在UserMapper接口中的方法上加上注解@Select,并在方法内部使用PageHelper.startPage方法开启分页,如下所示: ``` @Select("SELECT * FROM user") List<User> getUsers(); ``` 6. 运行项目,分页功能就会生效。 通过以上步骤,你就可以在Spring Boot项目中成功集成PageHelper分页插件了。<span class="em">1</span><span class="em">2</span><span class="em">3</span> #### 引用[.reference_title] - *1* [springboot整合分页插件PageHelper](https://blog.csdn.net/weixin_42408447/article/details/117528795)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v93^chatsearchT3_2"}}] [.reference_item style="max-width: 50%"] - *2* *3* [Springboot集成pagehelper 分页插件](https://blog.csdn.net/weixin_58696998/article/details/124397756)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v93^chatsearchT3_2"}}] [.reference_item style="max-width: 50%"] [ .reference_list ]
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值