Mybatis开启日志打印

1、方法一

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




    
        
        
    

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

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

2、方法二

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

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

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

3、方法三

springboot+mybatis-plus

  
       com.baomidou
       mybatis-plus-boot-starter
       3.3.1
  

application.yml

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

你可能感兴趣的:(mybatis,java,mysql)