三种环境
- dev:开发环境
- test:测试环境
- prod:生产环境
性能分析插件作用
- 性能分析拦截器,用于输出每条SQL语句及其执行时间
- SQL性能执行分析,开发环境使用,超过指定时间,停止运行,有助于发现问题
性能分析插件配置
-
在配置类中注册Bean
@Configuration // 表示配置类 @MapperScan("com.atguigu.mybatis_plus.mapper") // 把启动类中的移过来 public class EduConfig { /** * SQL执行性能分析插件 * 开发环境使用,线上不推荐。 maxTime指的是sql最大执行时长 */ @Bean @Profile({"dev","test"})// 设置 dev test 环境开启 public PerformanceInterceptor performanceInterceptor() { PerformanceInterceptor performanceInterceptor = new PerformanceInterceptor(); performanceInterceptor.setMaxTime(500); // ms,超过此处设置的ms则sql不执行 performanceInterceptor.setFormat(true); // SQL是否格式化,默认false return performanceInterceptor; } }
-
在application.properties中配置当前Spring Boot的环境
#环境设置:dev、test、prod spring.profiles.active=dev