• Mybatis-Plus配置性能分析插件


    三种环境
    1. dev:开发环境
    2. test:测试环境
    3. prod:生产环境
    性能分析插件作用
    1. 性能分析拦截器,用于输出每条SQL语句及其执行时间
    2. SQL性能执行分析,开发环境使用,超过指定时间,停止运行,有助于发现问题
    性能分析插件配置
    1. 在配置类中注册Bean

      @Configuration // 表示配置类
      @MapperScan("com.atguigu.mybatis_plus.mapper") // 把启动类中的移过来
      public class EduConfig {
          /**
           * SQL执行性能分析插件
           * 开发环境使用,线上不推荐。 maxTime指的是sql最大执行时长
           */
          @Bean
          @Profile({"dev","test"})// 设置 dev test 环境开启
          public PerformanceInterceptor performanceInterceptor() {
              PerformanceInterceptor performanceInterceptor = new PerformanceInterceptor();
              performanceInterceptor.setMaxTime(500); // ms,超过此处设置的ms则sql不执行
              performanceInterceptor.setFormat(true); // SQL是否格式化,默认false
              return performanceInterceptor;
          }
      }
      
      • 1
      • 2
      • 3
      • 4
      • 5
      • 6
      • 7
      • 8
      • 9
      • 10
      • 11
      • 12
      • 13
      • 14
      • 15
      • 16
    2. 在application.properties中配置当前Spring Boot的环境

      #环境设置:dev、test、prod
      spring.profiles.active=dev
      
      • 1
      • 2
  • 相关阅读:
    oracle数据导出exp导入imp
    【计算机视觉】OpenCV算法解析
    2023 我们一同走过
    C语言选择排序
    Python 面试高频问题:__init__ 和__new__的区别
    如何启动一个Vue项目
    接口请求加签名
    数组相关面试题--5.合并两个有序数组
    算法进阶-2sat-cf-1697F
    SQL 学习笔记
  • 原文地址:https://blog.csdn.net/qq_41829337/article/details/126213718