• 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. svn报错Item is not readable svn解决方案

    解决: 配置目录权限时如: [/]tangtx=rwyangcx=rwweishq=rw 结果组用户分别在根目录下可以正常show log,而在其子目录中show log都会提示 Item is no ...

  2. druid 连接池的配置参数

    介绍 DRUID是阿里巴巴开源平台上一个数据库连接池实现,它结合了C3P0.DBCP.PROXOOL等DB池的优点,同时加入了日志监控,可以很好的监控DB池连接和SQL的执行情况,可以说是针对监控而生 ...

  3. thymeleaf 设置display样式

    使用th:style标签: th:style="'display:' + @{(${value} ? 'none' : 'inline-block')} + ''" 其中value ...

  4. Golang 接口与反射知识要点

    目录 Golang 接口与反射知识要点 1. 接口类型变量 2. 类型断言 3. 鸭子类型 4. 反射机制 5. reflect 包 TypeOf().ValueOf() Type().Kind() ...

  5. <机器学习>无监督学习算法总结

    本文仅对常见的无监督学习算法进行了简单讲述,其他的如自动编码器,受限玻尔兹曼机用于无监督学习,神经网络用于无监督学习等未包括.同时虽然整体上分为了聚类和降维两大类,但实际上这两类并非完全正交,很多地方 ...

  6. 经典案例复盘——运维专家讲述如何实现K8S落地(摘抄)

    以下是运满满K8s容器化进程记录,摘抄一下,方便以后查阅. 背景介绍 运满满自开始微服务改造以来,线上线下已有数千个微服务的 Java 实例在运行中.这些 Java 实例部署在数百台云服务器或虚机上, ...

  7. 如何使用CSS实现居中

    前言: 这一篇主要是翻译 <how-to-center-anything-with-css>这一篇文章的主要内容,再加上自己的一些概括理解:主要问题是解决垂直居中的问题.我们知道实现水平居 ...

  8. Zookeeper监控(Zabbix)

      一直在弄监控,这些个中间件Zookeeper.Kafka......,平时也只知道一点皮毛,也就搭建部署过,没有真正的用过,一般都是大数据的同学在用,作为运维人员我需要对他做一个监控,由于对他不是 ...

  9. Scala 学习笔记之集合(4)

    集合的模式匹配操作: object CollectionDemo5 { def main(args: Array[String]): Unit = { //集合模式匹配1 val ls = List( ...

  10. maven打包工程出现错误 Failed to execute goal org.apache.maven.plugins:maven-surefire-plugin:2.12.4:test

    今天用maven在命令行打包项目的时候出现错误: Failed to execute goal org.apache.maven.plugins:maven-surefire-plugin:2.12. ...