zoukankan      html  css  js  c++  java
  • mybatisplus----性能分析插件

    性能分析插件


    我们在平时的开发中,会遇到一些慢sql。测试!druid,..

    作用:性能分析拦截器,用于输出每条SQL语句及其执行时间


    MP也提供性能分析插件,如果超过这个时间就停止运行!

    步骤:
    1、导入插件

        @Bean//性能分析插件
        @Profile({"dev", "test"})
        public PerformanceInterceptor performanceInterceptor() {
    
            PerformanceInterceptor performanceInterceptor = new PerformanceInterceptor();
            performanceInterceptor.setMaxTime(100);//设置最大执行时间是1毫秒,超过1毫秒则sql语句不执行
            performanceInterceptor.setFormat(true);//开启格式化支持(输出的sql更加清楚)
    
            return performanceInterceptor;
        }

    配置文件中配置环境:

    #配置性能分析插件(显示每一条sql语句,和他的执行时间)
    spring.profiles.active=dev


    2、测试使用!!

        @Test
        void contextLoads() {
            //继承了BaseMapper所有的方法都来自于父类,当然我们也可以定义自己的方法
    
            //参数wrapper是一个条件构造器
            List<User> users = userMapper.selectList(null);
            users.forEach(System.out::println);
        }

     测试结果:

    迎风少年
  • 相关阅读:
    30天自制操作系统之-第四天-
    30天自制操作系统之-第三天-
    30天自制操作系统之-第二天-
    30天自制操作系统之-第一天-
    c语言之连接符
    c语言之函数指针应用
    dpdk之路-环境部署
    linux系统裁剪
    redux和mobx比较(二)
    redux和mobx比较(一)
  • 原文地址:https://www.cnblogs.com/ZYH-coder0927/p/13970368.html
Copyright © 2011-2022 走看看