一、mybatisplus打印SQL语句
1、配置文件为application.yml格式
#mybatis-plus配置控制台打印完整带参数SQL语句
mybatis-plus:
configuration:
log-impl: org.apache.ibatis.logging.stdout.StdOutImpl
2、配置文件为application.properties格式
#mybatis-plus配置控制台打印完整带参数SQL语句
mybatis-plus.configuration.log-impl=org.apache.ibatis.logging.stdout.StdOutImpl
二、Springboot下jdbcTemplate打印SQL语句配置
1、方式一在yaml文件配置
logging:
level:
org.springframework.jdbc.core.JdbcTemplate: DEBUG
2、在logback.xml里加入如下配置
<include resource="org/springframework/boot/logging/logback/base.xml"/>
<logger name="org.springframework.jdbc.core" additivity="false" level="DEBUG" >
<appender-ref ref="CONSOLE" />
<appender-ref ref="FILE" />
</logger>
本文介绍了如何在MybatisPlus和Springboot中配置打印SQL语句。对于MybatisPlus,无论是application.yml还是application.properties文件,只需设置`mybatis-plus.configuration.log-impl`为`org.apache.ibatis.logging.stdout.StdOutImpl`即可。而在Springboot中,使用jdbcTemplate时,可以通过在yaml文件中将`org.springframework.jdbc.core.JdbcTemplate`的日志级别设置为DEBUG,或者在logback.xml中配置DEBUG级别的`org.springframework.jdbc.core`日志。
7915

被折叠的 条评论
为什么被折叠?



