zoukankan      html  css  js  c++  java
  • Mybatis-plus的两种分页插件的配置方式

    第一种:

    package com.paic.ocss.gateway.admin.config;
    
    import com.baomidou.mybatisplus.plugins.PaginationInterceptor;
    import org.mybatis.spring.annotation.MapperScan;
    import org.springframework.context.annotation.Bean;
    import org.springframework.context.annotation.Configuration;
    import org.springframework.context.annotation.Import;
    
    import com.baomidou.mybatisplus.entity.GlobalConfiguration;
    
    /**
     * mybatis的配置类
     *
     * @author zhangkai940
     * @date 2018-11-22
     */
    @Configuration
    @MapperScan({"com.paic.ocss.gateway.dao.mapper","com.paic.ocss.gateway.admin.mapper"})
    @Import(value = { com.paic.ocss.monitor.cat.mybatis.SpringCloudCatMybatisConfig.class })
    public class MybatisConfig {
    
        @Bean
        public GlobalConfiguration globalConfiguration() {
            GlobalConfiguration global = new GlobalConfiguration();
            global.setDbType("mysql");
            return global;
        }
    
        @Bean
        public PaginationInterceptor paginationInterceptor() {
            PaginationInterceptor page = new PaginationInterceptor();
            page.setDialectType("mysql");
            return page;
        }
    
    }

    第二种:

    package com.paic.ocss.gateway.dao.config;
    
    import com.baomidou.mybatisplus.entity.GlobalConfiguration;
    import com.github.pagehelper.PageHelper;
    import org.mybatis.spring.annotation.MapperScan;
    import org.springframework.context.annotation.Bean;
    import org.springframework.context.annotation.Configuration;
    import org.springframework.context.annotation.Import;
    
    import java.util.Properties;
    
    @Configuration
    @MapperScan("com.paic.ocss.gateway.dao.mapper*")
    @Import(value = { com.paic.ocss.monitor.cat.mybatis.SpringCloudCatMybatisConfig.class })
    public class MybatisConfig {
    
        @Bean
        public GlobalConfiguration globalConfiguration() {
            GlobalConfiguration global = new GlobalConfiguration();
            global.setDbType("mysql");
            return global;
        }
    
        /**
         * 配置mybatis的分页插件pageHelper
         * @return
         */
        @Bean
        public PageHelper pageHelper(){
            PageHelper pageHelper = new PageHelper();
            Properties properties = new Properties();
            properties.setProperty("offsetAsPageNum","true");
            properties.setProperty("rowBoundsWithCount","true");
            properties.setProperty("reasonable","true");
            //配置mysql数据库的方言
            properties.setProperty("dialect","mysql");
            pageHelper.setProperties(properties);
            return pageHelper;
        }
    
    }
  • 相关阅读:
    sql_mode=only_full_group_by引起group by查询报错问题
    在Eclipse下使用ant,build项目报jpeg does not exist
    JAVAEE面试之Hibernate缓存
    页面加载中效果实现
    鼠标滑过显示图片
    VSFTP配置参数详解
    FTP上传核心方法
    java对File的特殊操作
    在mybatis下使用日期比对出错
    Linux常用命令
  • 原文地址:https://www.cnblogs.com/leeego-123/p/10833079.html
Copyright © 2011-2022 走看看