Mybatis Plus 性能分析插件

本文最后更新于:2024年9月8日 晚上

Mybatis Plus 性能分析插件

配置插件

1
2
3
4
5
6
7
8
@Bean
@Profile({"dev","test"})// 设置 dev test 环境开启。
public PerformanceInterceptor performanceInterceptor() {
PerformanceInterceptor performanceInterceptor = new PerformanceInterceptor();
performanceInterceptor.setMaxTime(100); // ms设置sql执行的最大时间,如果超过了则不执行。
performanceInterceptor.setFormat(true); // 是否格式化代码。
return performanceInterceptor;
}

使用

  • 查询全部用户。
1
2
3
4
5
@Test
void contextLoads() {
List<User> users = userMapper.selectList(null);
users.forEach(System.out::println);
}
  • 如果超出设置的最大执行时间则会报错。

本博客所有文章除特别声明外,均采用 CC BY-SA 4.0 协议 ,转载请注明出处!