• pom.xml:

  <dependency>
<groupId>p6spy</groupId>
<artifactId>p6spy</artifactId>
<version>3.8.0</version>
</dependency>
  • application.yml 配置:

spring:
datasource:
driver-class-name: org.h2.Driver
url: jdbc:h2:tcp://192.168.180.115:19200/~/mem/test
username: root
password: test

mybatis-plus:
global-config:
db-config:
id-type: id_worker
capital-mode: true
configuration:
log-impl: org.apache.ibatis.logging.stdout.StdOutImpl
  • spy.properties 配置:

module.log=com.p6spy.engine.logging.P6LogFactory,com.p6spy.engine.outage.P6OutageFactory
# 自定义日志打印
logMessageFormat=com.baomidou.mybatisplus.extension.p6spy.P6SpyLogger
#日志输出到控制台
appender=com.baomidou.mybatisplus.extension.p6spy.StdoutLogger
# 使用日志系统记录 sql
#appender=com.p6spy.engine.spy.appender.Slf4JLogger
# 设置 p6spy driver 代理
deregisterdrivers=true
# 取消JDBC URL前缀
useprefix=true
# 配置记录 Log 例外,可去掉的结果集有error,info,batch,debug,statement,commit,rollback,result,resultset.
excludecategories=info,debug,result,batch,resultset
# 日期格式
dateformat=yyyy-MM-dd HH:mm:ss
# 实际驱动可多个
#driverlist=org.h2.Driver
# 是否开启慢SQL记录
outagedetection=true
# 慢SQL记录标准 2 秒
outagedetectioninterval=2
  • 配置类,官网已经弃用了插件,推荐使用P6spy

    @Configuration
    public class MybatisPlusConfig {

    // 该插件 3.1.2 后版本废弃,推荐使用
    // @Bean
    // public PerformanceInterceptor performanceInterceptor(){
    // //启用性能分析插件
    // return new PerformanceInterceptor();
    // }
    }
  • 实体类

    @Data
    @TableName(value = "student")
    public class Student {

    private Long id;

    private String name;

    private Integer age;

    }

    @Mapper
    public interface StudentMapper extends BaseMapper<Student> {


    }
  • 测试类


    @SpringBootTest
    class EanalysisApplicationTests {

    @Autowired
    private StudentMapper studentMapper;

    @Test
    public void test(){
    studentMapper.selectList(new QueryWrapper<>());
    }


    }
  • 测试结果

    2019-10-30 16:15:22.235  INFO 11508 --- [           main] com.zaxxer.hikari.HikariDataSource       : HikariPool-1 - Start completed.
    Consume Time:7 ms 2019-10-30 16:15:22
    Execute SQL:SELECT id,name,age FROM student

    2019-10-30 16:15:22.328 INFO 11508 --- [extShutdownHook] com.zaxxer.hikari.HikariDataSource

SpringBoot与MybatisPlus整合之SQL分析插件(六)的更多相关文章

  1. SpringBoot+Mybatis+MybatisPlus整合实现基本的CRUD操作

    SpringBoot+Mybatis+MybatisPlus整合实现基本的CRUD操作 1> 数据准备 -- 创建测试表 CREATE TABLE `tb_user` ( `id` ) NOT ...

  2. SpringBoot系列——MyBatis-Plus整合封装

    前言 MyBatis-Plus是一款MyBatis的增强工具(简称MP),为简化开发.提高效率,但我们并没有直接使用MP的CRUD接口,而是在原来的基础上封装一层通用代码,单表继承我们的通用代码,实现 ...

  3. SpringBoot与Mybatis-plus整合,代码生成mvc层

    一.添加pom依赖 <!-- mysql驱动 --> <dependency> <groupId>mysql</groupId> <artifac ...

  4. SpringBoot与MybatisPlus整合之公用字段填充(十一)

    在实际开发中,适合用于记录创建人修改人 pom.xml <dependencies> <dependency> <groupId>org.springframewo ...

  5. SpringBoot与MybatisPlus整合之活动记录(十五)

    活动记录和正常的CRUD效果是一样的,此处只当一个拓展,了解即可 pom.xml <dependencies> <dependency> <groupId>org. ...

  6. MyBatisPlus性能分析插件,条件构造器,代码自动生成器详解

    性能分析插件 我们在平时的开发中,会遇到一些慢sql,测试,druid MP(MyBatisPlus)也提供性能分析插件,如果超过这个时间就停止 不过官方在3.2版本的时候取消了,原因如下 条件构造器 ...

  7. 2、SpringBoot+MybatisPlus整合-------BaseCRUD

    开发工具:STS 代码下载链接:GitHub管理代码 版本: Springboot:1.5.14.RELEASE 使用2.0以上的Springboot,会报出一些异常.欢迎知道异常原因的大牛解惑. M ...

  8. SpringBoot+Mybatis-Plus整合Sharding-JDBC5.1.1实现单库分表【全网最新】

    一.前言 小编最近一直在研究关于分库分表的东西,前几天docker安装了mycat实现了分库分表,但是都在说mycat的bug很多.很多人还是倾向于shardingsphere,其实他是一个全家桶,有 ...

  9. 使用Springboot + Gradle快速整合Mybatis-Plus

    使用Springboot + Gradle快速整合Mybatis-Plus 作者:Stanley 罗昊 [转载请注明出处和署名,谢谢!] MyBatis-Plus(简称 MP)是一个 MyBatis ...

随机推荐

  1. .NetCore技术研究-一套代码同时支持.NET Framework和.NET Core

    在.NET Core的迁移过程中,我们将原有的.NET Framework代码迁移到.NET Core.如果线上只有一个小型的应用还好,迁移升级完成后,只需要维护.NET Core这个版本的代码. 但 ...

  2. springmvc(二)

    请求信息转换 异步发送表单数据到JavaBean,并响应JSON文本返回 操作步骤:(1)加入Jackson2或fastjson框架包,springmvc默认支持Jackon2,不需要做任何操作,而f ...

  3. springboot 集成Redis单机

    1.redis服务搭建 centos7 搭建redis服务 2.接入相关 pom文件依赖引入 <dependencies> <dependency> <groupId&g ...

  4. .NET进阶篇-语言章-1-Generic泛型深入

    内容目录 一.概述二.泛型的好处三.泛型使用1.泛型方法2.泛型类.泛型接口四.泛型的功能1.泛型中的默认值2.约束3.协变逆变5.泛型委托4.泛型缓存五.总结 一.概述 泛型我们一定都用过,最常见的 ...

  5. ELK 学习笔记之 Logstash之output配置

    Logstash之output配置: 输出到file 配置conf: input{ file{ path => "/usr/local/logstash-5.6.1/bin/spark ...

  6. FFmpeg(四) 像素转换相关函数理解

    一.基本流程 1.sws_getCachedContext();//得到像素转换的上下文 2.sws_scale()://进行转换 二.函数说明 1.SwsContext *vctx = NULL;  ...

  7. Linux入门(用户操作及权限)

    Linux入门之 用户操作及权限   在一个公司里,老板与员工有上下级之分,员工与员工间也有上下级或同级之分.每个级别在公司的职责不同,权限也不同.在Linux操作系统中也一样,不同的用户身份拥有着不 ...

  8. centos7版本以上root密码破解

    centos7版本以上root密码破解 主讲内容: 1.centos7版本以上root密码破解   一.centos7版本以上root密码破解 重启服务器,按键盘的方向键(上 下) 按e 进入紧急救援 ...

  9. 我的Java秋招面经大合集

    阿里面经   阿里中间件研发面经 蚂蚁金服研发面经 岗位是研发工程师,直接找蚂蚁金服的大佬进行内推. 我参与了阿里巴巴中间件部门的提前批面试,一共经历了四次面试,拿到了口头offer. 然后我也参加了 ...

  10. ios手机通过fiddler抓去Https协议包时证书问题

    解决Fiddler无法抓取ios端HTTPS请求的问题 南天E心 关注 2018.01.15 10:36 字数 281 阅读 909评论 0喜欢 0 近日公司服务升级,将所有的接口请求由HTTP升级为 ...