spring boot如何打印mybatis的执行sql

推荐免费的ChatGpt,微信注册即可使用

扫描图片上的二维码即可使用

方案一

application.properties配置:

 logging.level.com,后面的路径指的是mybatis对应的方法接口所在的包。并不是mapper.xml所在的包。

1.  logging.level.com.example.demo.dao=debug
2.  mybatis.configuration.log-impl=org.apache.ibatis.logging.stdout.StdOutImpl

在application.yml中增加配置,在控制台打印sql:

1. logging:
   level:
     com.example.demo.dao : debug
2. mybatis
   configuration:
    log-impl: org.apache.ibatis.logging.stdout.StdOutImpl 

参考类:org.apache.ibatis.session.Configuration
log-impl指定的值为org.apache.ibatis.logging.Log接口的某个实现类:

posted @ 2019-05-14 13:57  低调的小白  阅读(12077)  评论(0编辑  收藏  举报