/**
- SQL执行效率插件 性能分析插件
*/
@Bean
@Profile({“dev”,“test”})// 设置 dev test 环境开启
public PerformanceInterceptor performanceInterceptor() {
PerformanceInterceptor performanceInterceptor = new PerformanceInterceptor();
performanceInterceptor.setFormat(true);//格式化语句
//performanceInterceptor.setMaxTime(5);//执行时间超过多少秒会抛出异常
return performanceInterceptor;
}
执行sql打印
/**
-
插入一行user
-
执行时间50毫秒
-
Time:50 ms - ID:com.hlvy.mybatis_plus.mapper.UserMapper.selectById
-
Execute SQL:SELECT id,name,age,email,manager_id,created_time,update_time,version FROM User WHERE id=5 AND deleted=0
*/
@Test
public void insertUser() {
System.out.println((“----- insertUser method test ------”));
User user = new User();
user.setName(“恒果果”)