版权声明:此博客为个人博客,不涉及商业用途,仅提供学习参考,内容均来自个人原创以及互联网转载和摘录。 --------------------- 本文来自 路西法Lucifer 的CSDN 博客 ,全文地址请点击: https://blog.csdn.net/qq_37495786/article/details/82799910
springboot+mybatis整合过程中,开启控制台sql语句打印的两种方式:
方法一:
1.在mybatis的配置文件中添加:
<settings>
<!-- 打印sql日志 -->
<setting name="logImpl" value="STDOUT_LOGGING" />
</settings>
mybatis的配置文件----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的配置文件----appcation.yml中添加:
mybatis:
configuration:
log-impl: org.apache.ibatis.logging.stdout.StdOutImpl
ps:IDEA中,springboot默认配置文件是application.properties文件,但是yml文件在语法上更加简洁,更有层次感,所以此处是用yml语法,properties中好像是这么写的:mybatis.configuration.log-impl= org.apache.ibatis.logging.stdout.StdOutImpl
控制台可以打印了。。。。。
方法二:
在springboot+mybatis整合中,可以将springboot的配置文件添加如下一段也可:
logging:
level:
com.lucifer.springboot.cache.mapper: debug
ps:com.lucifer.springboot.cache.mapper是包名