springboot mybatis打印sql语句怎么配置

avatar
作者
筋斗云
阅读量:0

在Spring Boot项目中使用MyBatis打印SQL语句有两种常用的配置方式:

  1. 使用MyBatis的配置文件配置: 在MyBatis的配置文件(通常是mybatis-config.xml)中添加如下配置:
<settings>     <setting name="logImpl" value="LOG4J2"/> settings> 

这样就可以将SQL语句打印到日志中。

  1. 使用Spring Boot的配置文件配置: 在application.properties或application.yml中添加如下配置:
mybatis.configuration.log-impl=org.apache.ibatis.logging.stdout.StdOutImpl 

这样也可以将SQL语句打印到控制台中。

通过以上配置,可以在控制台或日志中看到MyBatis执行的SQL语句,方便调试和优化SQL。

    广告一刻

    为您即时展示最新活动产品广告消息,让您随时掌握产品活动新动态!