性能分析插件
1、 作用
性能分析拦截器,用于输出每条SQL语句及其执行时间
2、 注册性能分析插件
// SQL执行效率插件
@Bean
@Profile({"dev","test"}) // 设置 dev test 环境开启,保证生产效率
public PerformanceInterceptor performanceInterceptor() {
PerformanceInterceptor performanceInterceptor = new PerformanceInterceptor();
performanceInterceptor.setMaxTime(1);//ms 设置sql执行最大时间,如果超过了则不执行
performanceInterceptor.setFormat(true);// 开启格式化支持
return performanceInterceptor;
}
3、 设置开发环境
#设置开发环境
spring.profiles.active=dev
4、 测试查询全部用户
// 查询所有用户
@Test
void contextLoads() {
//查询全部用户
List<User> userList = userMapper.selectList(null);
userList.forEach(System.out::println);
}
5、 观察输出结果
条件构造器
##1、 六个测试案例
package com.will;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.will.mapper.UserMapper;
import com.will.pojo.User;
import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import java.util.List;
@SpringBootTest
public class WrapperTests {
@Autowired
private UserMapper userMapper;
@Test
void contextLoads() {
// 查询 n