Mybatis-plus打印完整执行sql

目录

前言

使用

效果


前言

如果你恰好使用 Mybatis-plus 框架,那么在开发环境就不能错过它提供的 PerformanceInterceptor 插件,该插件能打印 sql 执行时间以及完整的 sql 语句,非常方便复制出来分析 sql 

使用

这里使用的 Mybatis-plus 框架比较老,是 2.3 版本的,引入依赖,然后实例化 PerformanceInterceptor 插件即可,如下

<dependency>
            <groupId>com.baomidou</groupId>
            <artifactId>mybatis-plus-boot-starter</artifactId>
            <version>2.3</version>
            <exclusions>
                <exclusion>
                    <artifactId>tomcat-jdbc</artifactId>
                    <groupId>org.apache.tomcat</groupId>
                </exclusion>
            </exclusions>
        </dependency>
@Bean
    @Profile({"dev", "test"})
    public PerformanceInterceptor performanceInterceptor() {
        PerformanceInterceptor performanceInterceptor = new PerformanceInterceptor();
        performanceInterceptor.setMaxTime(15000);
        performanceInterceptor.setFormat(false);
        return performanceInterceptor;
    }

效果

此时打印出来的 sql 便不会带有 ?,而是拼接完参数后的完整 sql  

猜你喜欢

转载自blog.csdn.net/m0_38001814/article/details/120953039