zoukankan      html  css  js  c++  java
  • pagehelper配置 多数据源自动切换数据库方言 mysql/sqlserver/oracle等数据库

    1 加入依赖

    <dependency>
    <groupId>com.github.pagehelper</groupId>
    <artifactId>pagehelper</artifactId>
    <version>5.1.10</version>
    </dependency>
    2、配置分页插件

    import com.github.pagehelper.PageInterceptor;
    import org.springframework.context.annotation.Bean;
    import org.springframework.context.annotation.Configuration;
    import java.util.Properties;
    /**
    * 描述:分页组件设置
    *
    * @author: Adobe Chow
    * @date: 2019/11/4 10:24
    * @Copyright: www.winshang.com Inc. All rights reserved.
    */
    @Configuration
    public class PageHelperConfig {

    @Bean
    PageInterceptor pageInterceptor(){
    PageInterceptor pageInterceptor = new PageInterceptor();
    Properties properties = new Properties();
    properties.setProperty("offsetAsPageNum","false");
    properties.setProperty("rowBoundsWithCount","false");
    properties.setProperty("pageSizeZero","true");
    properties.setProperty("reasonable","false");
    properties.setProperty("supportMethodsArguments","false");
    properties.setProperty("returnPageInfo","none");
    properties.setProperty("autoRuntimeDialect","true");
    pageInterceptor.setProperties(properties);
    return pageInterceptor;
    }

    }

    或者配置mybatis-config.xml

    <plugins>
    <plugin interceptor="com.github.pagehelper.PageInterceptor">
    <property name="offsetAsPageNum" value="false" />
    <property name="rowBoundsWithCount" value="false" />
    <property name="pageSizeZero" value="true" />
    <property name="reasonable" value="false" />
    <property name="supportMethodsArguments" value="false" />
    <property name="returnPageInfo" value="none" />
    <!--<property name="dialect" value="mysql" />-->
    <property name="autoRuntimeDialect" value="true" />
    <!--<property name="autoDialect" value="true" />-->
    </plugin>
    </plugins>

    使用

    @ResponseBody
    @PostMapping("myActivityList")
    public PageInfo myActivityList(@RequestBody ActivityListDto dto){
    PageHelper.startPage(1,10);
    return new PageInfo(activityManagerService.myActivityList(dto));
    }

  • 相关阅读:
    shell (3) 磁盘挂载
    QByteArray 内存拷贝异常
    记录QTextEdit
    QTableWidget 使用
    QT 读写xml
    远程工具长时间待机断网解决办法
    qt读写json文件
    QT 资源文件(.qrc)
    error: C1041: 无法打开程序数据库“E:ProjectQtuild-QCaculator-Desktop_Qt_5_14_1_MSVC2017_32_bit-DebugdebugQCaculator.vc.pdb”;如果要将多个 CL.EXE 写入同一个 .PDB 文件,请使用 /FS
    Vs2019+Qt5.14环境配置,安装qt visual studio tools报错。
  • 原文地址:https://www.cnblogs.com/liangmm/p/12068392.html
Copyright © 2011-2022 走看看