栏目分类:
子分类:
返回
名师互学网用户登录
快速导航关闭
当前搜索
当前分类
子分类
实用工具
热门搜索
名师互学网 > IT > 软件开发 > 后端开发 > Java

SpringBoot项目中分页插件PageHelper无效的问题及解决方法

Java 更新时间: 发布时间: IT归档 最新发布 模块sitemap 名妆网 法律咨询 聚返吧 英语巴士网 伯小乐 网商动力

SpringBoot项目中分页插件PageHelper无效的问题及解决方法

在Springboot项目中使用分页插件的时候 发现PageHelper插件失效了

我导入的是:

后来才发


 com.github.pagehelper
 pagehelper
 5.1.10

现 PageHelper若要在Springboot中使用 是需要进行注入的:

@Configuration
public class mybatisConfiguration {
@Bean
public PageHelperpageHelper(){
System.out.println("MybatisConfiguration.pageHelper()");
 PageHelper pageHelper =new PageHelper();
 Properties properties =new Properties();
 properties.setProperty("offsetAsPageNum","true");
 properties.setProperty("rowBoundsWithCount","true");
 properties.setProperty("reasonable","true");
 pageHelper.setProperties(properties);
 return pageHelper;
 }
}

当然 也可使用Springboot PageHelper启动器 无需注入 开箱即用 更推荐此方法:


 com.github.pagehelper
 pagehelper-spring-boot-starter
 1.2.10

PS:SpringBoot项目和Spring项目依赖分页插件Pagehelper不起作用的问题

最近在SpringBoot项目和Spring项目同时开发,两个项目都依赖了Mybatis框架里的pagehelper分页插件,但是SpringBoot项目分页不起作用,一直查询出所有数据。

错误原因:两项目都引入的依赖为

 
      com.github.pagehelper
      pagehelper
      4.0.0
    

解决办法:经过多次调查试验,发现SpringBoot项目依赖的分页插件和Spring项目有所不同,需要spring-boot-starter下的包才可以。所以SpringBoot项目需要配置下面的依赖即可:

 
      com.github.pagehelper
      pagehelper-spring-boot-starter
      1.2.5
    

总结

到此这篇关于SpringBoot项目中分页插件PageHelper无效的问题及解决方法的文章就介绍到这了,更多相关SpringBoot分页插件PageHelper无效内容请搜索考高分网以前的文章或继续浏览下面的相关文章希望大家以后多多支持考高分网!

转载请注明:文章转载自 www.mshxw.com
本文地址:https://www.mshxw.com/it/133803.html
我们一直用心在做
关于我们 文章归档 网站地图 联系我们

版权所有 (c)2021-2022 MSHXW.COM

ICP备案号:晋ICP备2021003244-6号