SpringBoot的 Mybatis Plus分页插件

分享一个 MybatisPlusConfig.java,一个mybatisPlus的配置文件,配置后可以使用mybatisPlus的物理分页,以及在dev环境下格式化打印sql

package com.wpg.meter.common.config;

import com.baomidou.mybatisplus.plugins.PaginationInterceptor;
import com.baomidou.mybatisplus.plugins.PerformanceInterceptor;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Profile;

/**
 * MybatisPlus 插件配置
 * @author leo
 * @version 1.0.0
 * @date 2018-09-02 14:53:47
 */
@Configuration
public class MybatisPlusConfig {

    @Bean
    public PaginationInterceptor paginationInterceptor() {
        PaginationInterceptor paginationInterceptor = new PaginationInterceptor();
        paginationInterceptor.setDialectType("mysql");

        return paginationInterceptor;
    }

    @Bean
    @Profile("dev")
    public PerformanceInterceptor performanceInterceptor() {
        PerformanceInterceptor performanceInterceptor = new PerformanceInterceptor();
        performanceInterceptor.setFormat(true);    // dev环境,格式化输出的sql语句
        performanceInterceptor.setMaxTime(5000);
        return performanceInterceptor;
    }

}

其他详细说明,请转

https://blog.csdn.net/apicescn/article/details/79554597

你可能感兴趣的:(SpringBoot)