• 分页查询


    1.使用分页插件pagehelper

    1.1pom文件

    <!--数据库:druid连接池-->
    <dependency>
    <groupId>com.alibaba</groupId>
    <artifactId>druid</artifactId>
    <version>1.1.6</version>
    </dependency>
    <!--数据库:postgresql驱动-->
    <dependency>
    <groupId>org.postgresql</groupId>
    <artifactId>postgresql</artifactId>
    <version>9.4.1208</version>
    </dependency>
    <!--数据库:mapper-->
    <dependency>
    <groupId>tk.mybatis</groupId>
    <artifactId>mapper-spring-boot-starter</artifactId>
    <version>1.2.4</version>
    </dependency>
    <!--分页插件:pagehelper-->
    <dependency>
    <groupId>com.github.pagehelper</groupId>
    <artifactId>pagehelper-spring-boot-starter</artifactId>
    <version>1.2.4</version>
    </dependency>
    <dependency>
    <groupId>org.apache.commons</groupId>
    <artifactId>commons-lang3</artifactId>
    <version>3.7</version>
    </dependency>

    1.2 application文件

    # mybatis 配置
    mybatis:
    mapper-locations: classpath:mapper/*.xml
    configuration:
    #控制台输出SQL操作语句
    log-impl: org.apache.ibatis.logging.stdout.StdOutImpl
    #分页插件配置
    pagehelper:
    helperDialect: postgresql
    reasonable: true
    support-methods-arguments: true
    params: count=countSql

    1.3 实体

     1.4 mapper文件

     

     1.5分页实现

     

    2.mybatis-plus分页

    2.1pom文件

    <!--数据库:druid连接池-->
    <dependency>
    <groupId>com.alibaba</groupId>
    <artifactId>druid</artifactId>
    <version>1.1.6</version>
    </dependency>
    <!--数据库:postgresql驱动-->
    <dependency>
    <groupId>org.postgresql</groupId>
    <artifactId>postgresql</artifactId>
    <version>9.4.1208</version>
    </dependency>
    <!--mybatis plus-->
    <dependency>
    <groupId>com.baomidou</groupId>
    <artifactId>mybatis-plus-boot-starter</artifactId>
    <version>3.2.0</version>
    </dependency>

    2.2application配置

    #mybatis相关配置
    mybatis:
    mapper-locations: classpath:mapper/*.xml
    configuration:
    log-impl: org.apache.ibatis.logging.stdout.StdOutImpl

    2.3分页插件类

     2.4实体类

    2.5分页实现

     

     3.结束

  • 相关阅读:
    Spark ML参考博客
    Mysql数据库相关
    git clone server certificate verification failed
    GSM网络扫频结果
    USRP E310启用SSH的X11 Forwarding功能
    Win 7 SVN查看日志时出现There has been a problem contacting the server
    OpenWrt修改MAC地址
    NETGEAR WNDR4300路由器tftp方式 刷机
    ubuntu系统中修改hostname
    USRP中sampling rate和master clock rate的区别
  • 原文地址:https://www.cnblogs.com/CookiesBear/p/11989501.html
Copyright © 2020-2023  润新知