• 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));
    }

  • 相关阅读:
    delphi idhttpserver ajax 跨域解决方法
    【转】安卓apk反编译(三件套) (com.googlecode.d2j.DexException: not support version问题解决)
    C++ volatile的作用
    GetProcAddress函数
    c++ CArray函数
    CString中TrimLeft()与TrimRight()的用法
    使用Windows API进行串口编程
    SetCommMask
    AttachThreadInput
    关于CoInitialize和CoUninitialize调用的有关问题
  • 原文地址:https://www.cnblogs.com/liangmm/p/12068392.html
Copyright © 2020-2023  润新知