在调试问题时经常需要打印具体的执行SQL,需要开启SQL打印,这里做下记录
以application.properties文件为例,添加以下配置即可
mybatis.configuration.log-impl=org.apache.ibatis.logging.stdout.StdOutImpl
如果是添加了mybatis-spring-boot-starter整合依赖的,直接在配置文件中使用下面方式
logging.level.com.lucifer.springboot.cache.mapper=debug
如果添加的是mybatis-plus或者mybatis-plus-boot-starter整合依赖的话,在配置文件中使用下面方式
mybatis-plus.configuration.log-impl=org.apache.ibatis.logging.stdout.StdOutImpl
打印出来的示例如下
Registering transaction synchronization for SqlSession [org.apache.ibatis.session.defaults.DefaultSqlSession@69fe8f8a]
JDBC Connection [io.shardingsphere.shardingjdbc.jdbc.core.connection.ShardingConnection@615a03bc] will be managed by Spring
==> Preparing: SELECT a.template_site_id,a.lv_site_name,a.lv_