mybatis-plus在控制台输出sql

有两种实现方式

 

一、在application.yml添加如下配置

mybatis-plus:
#  config-location: classpath:mybatis/mybatis-config.xml
  mapper-locations: classpath*:mybatis/mapper/**/*.xml
  configuration:
    log-impl: org.apache.ibatis.logging.stdout.StdOutImpl

这种方式,是通过

  configuration:
    log-impl: org.apache.ibatis.logging.stdout.StdOutImpl

实现的,需要注意的,这个配置,不能与config-location: classpath:mybatis/mybatis-config.xml 同时存在,因此必须注释掉这一行。但是这样做,会导致控制台的输出都是黑色的,控制台看不到高亮的输出了,所以这种方法不是最好的,下面来看,第二种方法:

 

二、通过mybatis-config.xml的配置实现控制台输出sql,实现方法是,在settings节点加入下面这句:

        <!-- 打印sql语句 -->
        <setting name="logImpl" value="STDOUT_LOGGING" />

 

参考资料:

https://blog.csdn.net/jiangchao858/article/details/115676371

https://blog.csdn.net/qq_30038111/article/details/116723492

https://gitee.com/Handsomeztxue/template/blob/master/src/main/resources/log4j2.xml

https://qa.1r1g.com/sf/ask/1068070111/

posted @   jamstack  阅读(5089)  评论(0编辑  收藏  举报
相关博文:
阅读排行:
· Manus重磅发布:全球首款通用AI代理技术深度解析与实战指南
· 被坑几百块钱后,我竟然真的恢复了删除的微信聊天记录!
· 没有Manus邀请码?试试免邀请码的MGX或者开源的OpenManus吧
· 园子的第一款AI主题卫衣上架——"HELLO! HOW CAN I ASSIST YOU TODAY
· 【自荐】一款简洁、开源的在线白板工具 Drawnix
点击右上角即可分享
微信分享提示