Springboot中mybatis控制台打印sql语句

1、SpringBoot使用logback输出日志并打印sql信息
Springboot中只需要在application.yml配置文件中加上

logImpl: org.apache.ibatis.logging.stdout.StdOutImpl

完整的配置文件

mybatis:
  configuration:
    mapUnderscoreToCamelCase: true
    logImpl: org.apache.ibatis.logging.stdout.StdOutImpl
    typeAliasesPackage: com.jsptpd.gayg.modules
  mapperLocations: classpath:com/jsptpd/gayg/**/*.xml

spring:
  resource: 
    static-locations: file:/public/
  http:
    multipart:
      max-file-size: 20Mb
      max-request-size: 80Mb
  profiles:
    active: dev

Debug模式下有断点会进入断点,想要查看控制台的sql语句需要切换Debugger/Console

《Springboot中mybatis控制台打印sql语句》 Debug模式下切换查看控制台输出.png

2、如果是Spring 4.0.2 + Spring MVC 4.0.2 + MyBatis 3.2.6架构

MyBatis3 用log4j在控制台输出 SQL

mybatis配置log4j控制台打印SQL语句

spring boot 整合 log4j 控制台打印sql(mybatis)

    原文作者:墨色尘埃
    原文地址: https://www.jianshu.com/p/3cfe5f6e9174
    本文转自网络文章,转载此文章仅为分享知识,如有侵权,请联系博主进行删除。
点赞