• 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. 读《深入理解Elasticsearch》点滴-对象类型、嵌套文档、父子关系

    一.对象类型 1.mapping定义文件 "title":{ "type":"text" }, "edition":{ ...

  2. Activiti(1) - TaskRuntime API 入门

    目录 TaskRuntime API pom.xml 注册TaskRuntime实例 角色与分组 任务事件监听器 DemoApplication 源码 Activiti 是一个自动化工作流框架.它能帮 ...

  3. HttpClient连接池的一些思考

    前言 使用apache的httpclient进行http的交互处理已经很长时间了,而httpclient实例则使用了http连接池,想必大家也没有关心过连接池的管理.事实上,通过分析httpclien ...

  4. RocketMQ 源码学习笔记————Producer 是怎么将消息发送至 Broker 的?

    目录 RocketMQ 源码学习笔记----Producer 是怎么将消息发送至 Broker 的? 前言 项目结构 rocketmq-client 模块 DefaultMQProducerTest ...

  5. 【python小随笔】字典的使用

    字典也是 Python 提供的一种常用的数据结构,它用于存放具有映射关系的数据. 比如有份成绩表数据,语文:79,数学:80,英语:92,这组数据看上去像两个列表,但这两个列表的元素之间有一定的关联关 ...

  6. 快学Scala 第六课 (类getter和setter)

    类getter和setter 如果字段定义是private[this], 字段是私有的,但不生成getter和setter方法. class Counter { private[this] var v ...

  7. Spring Cloud Feign 总结问题,注意点,性能调优,切换okhttp3

    ### Feign常见问题总结 **FeignClient接口如使用`@PathVariable` ,必须指定value属性** ```java //在一些早期版本中, @PathVariable(& ...

  8. 各种常见文件的hex文件头

    我们在做ctf时,经常需要辨认各种文件头,跟大家分享一下一些常见的文件头.   扩展名 文件头标识(HEX) 文件描述 123 00 00 1A 00 05 10 04 Lotus 1-2-3 spr ...

  9. Hive 官方手册翻译 -- Hive DDL(数据定义语言)

    Hive DDL(数据定义语言) Confluence Administrator创建, Janaki Lahorani修改于 2018年9月19日 原文链接 https://cwiki.apache ...

  10. Numpy数组操作

    """ Numpy 数组操作 修改数组形状 函数 描述 reshape 不改变数据的条件下修改形状 flat 数组元素迭代器 flatten 返回一份数组拷贝,对拷贝所做 ...