当前位置:   article > 正文

springboot + mybatis开启日志打印

mybatis开启日志打印

1、方法一

mybatis的添加配置文件----mybatis-config.xml如下

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

springboot的配置文件----appcation.yml中添加

  1. mybatis:
  2. configuration:
  3. log-impl: org.apache.ibatis.logging.stdout.StdOutImpl
mybatis.configuration.log-impl= org.apache.ibatis.logging.stdout.StdOutImpl

2、方法二

springboot+mybatis整合中,可以将springboot的配置文件添加

  1. logging:
  2. level:
  3. com.lucifer.springboot.cache.mapper: debug

com.lucifer.springboot.cache.mapper是包名

3、方法三

springboot+mybatis-plus

  1. <dependency>
  2. <groupId>com.baomidou</groupId>
  3. <artifactId>mybatis-plus-boot-starter</artifactId>
  4. <version>3.3.1</version>
  5. </dependency>

application.yml

  1. mybatis-plus:
  2. configuration:
  3. log-impl: org.apache.ibatis.logging.stdout.StdOutImpl
  1. JDBC Connection [HikariProxyConnection@1006460161 wrapping com.mysql.cj.jdbc.ConnectionImpl@37cccae8] will not be managed by Spring
  2. ==> Preparing: SELECT id,user_name,age FROM user WHERE (user_name = ?)
  3. ==> Parameters: 张三(String)
  4. <== Columns: id, user_name, age
  5. <== Row: 1, 张三, 18
  6. <== Total: 1

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/笔触狂放9/article/detail/599931
推荐阅读
相关标签
  

闽ICP备14008679号