zoukankan      html  css  js  c++  java
  • 如何让SpringBoot工程在log/控制台中实时打印MyBatis执行的SQL语句

    工程下载:https://files.cnblogs.com/files/xiandedanteng/gatling20200429-4.zip

    其实就是一句话设置的事情,实现步骤:

    在application.properties中书写

    logging.level.com.ufo.gatling.mapper.EmpMapper=debug

    这样一行,其中com.ufo.gatling.mapper.EmpMapper为我工程中与DB交互的类

    之后执行起来,就能看到SQL输出了,示例如下:

    04-29 15:56:53.030 - ==>  Preparing: select b.* from (select a.*,rownum as rn from (select * from hy_emp order by id) a where rownum<101) b where b.rn>90 
    2020-04-29 15:56:53.102 - ==> Parameters: 
    2020-04-29 15:56:53.135 - <==      Total: 10
    2020-04-29 15:56:53.138 - ==>  Preparing: select count(*) from hy_emp 
    2020-04-29 15:56:53.138 - ==> Parameters: 
    2020-04-29 15:56:53.144 - <==      Total: 1
    2020-04-29 15:57:15.018 - ==>  Preparing: select b.* from (select a.*,rownum as rn from (select * from hy_emp order by id) a where rownum<111) b where b.rn>100 
    2020-04-29 15:57:15.019 - ==> Parameters: 
    2020-04-29 15:57:15.030 - <==      Total: 10
    2020-04-29 15:57:15.031 - ==>  Preparing: select count(*) from hy_emp 
    2020-04-29 15:57:15.032 - ==> Parameters: 
    2020-04-29 15:57:15.036 - <==      Total: 1
    2020-04-29 15:57:16.744 - ==>  Preparing: select b.* from (select a.*,rownum as rn from (select * from hy_emp order by id) a where rownum<101) b where b.rn>90 
    2020-04-29 15:57:16.744 - ==> Parameters: 
    2020-04-29 15:57:16.754 - <==      Total: 10
    2020-04-29 15:57:16.755 - ==>  Preparing: select count(*) from hy_emp 
    2020-04-29 15:57:16.755 - ==> Parameters: 
    2020-04-29 15:57:16.760 - <==      Total: 1

    相对于旧版本的SQL与参数分离,当前工程的SQL是一起输出了,这点改进不错。

    --2020-04-29--

    参考文档:https://www.cnblogs.com/mww-NOTCOPY/p/10990492.html

  • 相关阅读:
    Alpha冲刺博客集
    Alpha冲刺——第一天
    团队项目需求分析
    结对第二次作业
    项目选题报告
    随笔2 PAT1001.A+B Format (20)
    随笔1 大一下学期自我目标
    大数
    列变位法解密--百度之星B题
    hdu1874 畅通工程续 dijkstra 最短路
  • 原文地址:https://www.cnblogs.com/heyang78/p/12802300.html
Copyright © 2011-2022 走看看