Mybatis 开启控制台打印sql语句

文章目录

    • 框架1:SpringMVC
    • 框架2 SpringBoot +Mybatis
    • 框架3 springboot+mybatis-plus

框架1:SpringMVC

在mybatis-config.xml 配置文件里添加

<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE configuration
        PUBLIC "-//mybatis.org//DTD Config 3.0//EN"
        "http://mybatis.org/dtd/mybatis-3-config.dtd">
<configuration>
    <settings>
        <!-- 打印sql日志 -->
        <setting name="logImpl" value="STDOUT_LOGGING" />
    </settings>
</configuration>

框架2 SpringBoot +Mybatis

方法一:
appcation.yml中添加:

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

方法二:

logging:
  level:
    com.lucifer.springboot.cache.mapper: debug

框架3 springboot+mybatis-plus

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

你可能感兴趣的:(mybatis,sql,数据库)