在SpringBoot中集成MyBatis日志功能可以通過配置MyBatis的日志實(shí)現(xiàn)來(lái)實(shí)現(xiàn)。下面是一種常見的集成方法:
<dependency>
<groupId>org.mybatis.spring.boot</groupId>
<artifactId>mybatis-spring-boot-starter</artifactId>
<version>2.2.0</version>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-log4j2</artifactId>
</dependency>
# 配置 MyBatis 打印 SQL 日志
mybatis.configuration.log-impl=org.apache.ibatis.logging.log4j2.Log4j2Impl
<Logger name="org.apache.ibatis" level="DEBUG" additivity="false">
<AppenderRef ref="STDOUT"/>
</Logger>
這樣就可以在控制臺(tái)或者日志文件中看到MyBatis執(zhí)行的SQL語(yǔ)句和相關(guān)信息了。通過以上步驟,就可以實(shí)現(xiàn)在SpringBoot中集成MyBatis的日志功能了。