zoukankan      html  css  js  c++  java
  • PageHelper 分页插件

             <dependency>
                  <groupId>com.github.pagehelper</groupId>
                  <artifactId>pagehelper</artifactId>
                <version>5.1.8</version>
            </dependency>
            <dependency>
                <groupId>com.github.pagehelper</groupId>
                <artifactId>pagehelper-spring-boot-autoconfigure</artifactId>
                <version>1.2.10</version>
            </dependency>
            <dependency>
                <groupId>com.github.pagehelper</groupId>
                <artifactId>pagehelper-spring-boot-starter</artifactId>
                <version>1.2.10</version>
            </dependency>

     mybatis分页需要引入的依赖

    最近看到分页插件pageHelper 会有效率问题

    大多数人跟我一样,最开始接触PageHelper的时候,都被超级方便的分页操作吸引

    有多方便?

    public PageInfo querySharePage(QueryObject qo) {
            PageHelper.startPage(qo.getCurrentPage(), qo.getPageSize());
            List<ShareTrainHh> shareList = trainHhMapper.selectAll();
            return new PageInfo(shareList);
    }
    

    一个普通的分页功能,从头到尾只需要三句代码

    配置文件:

    如果使用单数据源,可在配置文件中配置如下:
    pagehelper:
      helperDialect: mysql
      reasonable: false
      supportMethodsArguments: true
      params: count=countSql
    
    如果使用多数据源,需要修改pagehelper配置项,配置如下
    pagehelper:
    #  helperDialect: mysql
      reasonable: false
      supportMethodsArguments: true
      params: count=countSql
    # 默认false,当为true时,自动检验适合的数据库 
      auto-dialect: true
       # 这个一定要加上,不然mysql和sqlserver分页两个只能用一个,另一个会报错,加上后,两中数据库分页都可以用了
      auto-runtime-dialect: true

    但是!

    数据量大一点的表,千万不要随便拿来就用!



    作者:烛火下的乌托邦丶
    参考原文链接:https://www.jianshu.com/p/88d1eca40271
    源码,是痛苦的,又是快乐的,如果没有这痛苦,也就没有了这快乐!
  • 相关阅读:
    09.Java数据算法
    08.Java反射问题
    07.Java类加载问题
    占位
    占位
    占位
    占位
    HTML与CSS粗浅摘要
    JavaScript(4):模态对话框、隐藏二级菜单及多选框的实现
    JavaScript(3):DOM选择器
  • 原文地址:https://www.cnblogs.com/erlongxizhu-03/p/10671615.html
Copyright © 2011-2022 走看看