性能分析插件
我们在平时的开发中,会遇到一些慢Sql。测试、druid···
MybatisPlus也提供了性能分析插件,如果超过这个时间就停止运行!
性能分析拦截器作用:用于输出每条sql语句及其执行时间
1、导入插件
- config - MyBatisPlusConfig
@Bean
@Profile({"dev","test"})
public PerformanceInterceptor performanceInterceptor(){PerformanceInterceptor performanceInterceptor = new PerformanceInterceptor();performanceInterceptor.setMaxTime(100);performanceInterceptor.setFormat(true);return performanceInterceptor;
}
注意: 要在SpringBoot中配置环境为dev或test环境!
#设置开发环境
spring.profiles.active=dev
2、测试使用
@Testpublic void testSelectById(){User user = userMapper.selectById(1L);System.out.println(user);}
3.查看控制台
使用性能分析插件,可以帮助我们提高效率!