【Cause: com.baomidou.mybatisplus.core.exceptions.MybatisPlusException: The SQL execution time is t】

报错阐述:

使用mybatis_plus配置了sql执行性能分析插件,配置好之后报错如下:

org.mybatis.spring.MyBatisSystemException: nested exception is org.apache.ibatis.exceptions.PersistenceException: 
### Error querying database.  Cause: com.baomidou.mybatisplus.core.exceptions.MybatisPlusException:  The SQL execution time is too large, please optimize ! 
### The error may exist in com/example/cronmall/mapper/UserMapper.java (best guess)
### The error may involve com.example.cronmall.mapper.UserMapper.selectById
### The error occurred while handling results
### SQL: SELECT id,name,age,email,create_time,update_time,version,deleted FROM user WHERE id=?  AND deleted=0
### Cause: com.baomidou.mybatisplus.core.exceptions.MybatisPlusException:  The SQL execution time is too large, please optimize ! 

报错原因

是因为设置的最大执行时长太小了。查询时间34ms,而设置的最大执行时长为10ms。

Time:34 ms - ID:com.example.cronmall.mapper.UserMapper.selectById

解决方案

修改执行最大时长到一个合适的数值,如下所示:

@Bean
    @Profile({"dev", "test"})// 设置dev test环境开启
    public PerformanceInterceptor performanceInterceptor() {
        PerformanceInterceptor performanceInterceptor = new PerformanceInterceptor();
        performanceInterceptor.setMaxTime(500);//ms,超过此处设置的ms则sql不执行
        performanceInterceptor.setFormat(true);
        return performanceInterceptor;
    }
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值