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 @ 2022-04-25 23:02  jamstack  阅读(4950)  评论(0编辑  收藏  举报