From 4e06242d06a39f190b68b47150361bc602b4f013 Mon Sep 17 00:00:00 2001 From: Suomm <1474983351@qq.com> Date: Fri, 17 Nov 2023 23:39:04 +0800 Subject: [PATCH] =?UTF-8?q?test:=20=E6=B7=BB=E5=8A=A0=20SQL=20=E6=A0=BC?= =?UTF-8?q?=E5=BC=8F=E5=8C=96=E8=BE=93=E5=87=BA=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/com/mybatisflex/test/SampleApplication.java | 9 +++++---- mybatis-flex-test/pom.xml | 8 ++++++++ 2 files changed, 13 insertions(+), 4 deletions(-) diff --git a/mybatis-flex-test/mybatis-flex-spring-boot-test/src/main/java/com/mybatisflex/test/SampleApplication.java b/mybatis-flex-test/mybatis-flex-spring-boot-test/src/main/java/com/mybatisflex/test/SampleApplication.java index 31632080..91232449 100644 --- a/mybatis-flex-test/mybatis-flex-spring-boot-test/src/main/java/com/mybatisflex/test/SampleApplication.java +++ b/mybatis-flex-test/mybatis-flex-spring-boot-test/src/main/java/com/mybatisflex/test/SampleApplication.java @@ -15,6 +15,7 @@ */ package com.mybatisflex.test; +import com.github.vertical_blank.sqlformatter.SqlFormatter; import com.mybatisflex.core.audit.AuditManager; import com.mybatisflex.core.audit.ConsoleMessageCollector; import com.mybatisflex.core.audit.MessageCollector; @@ -50,11 +51,11 @@ public class SampleApplication implements CommandLineRunner, ApplicationListener @Override public void onApplicationEvent(ContextRefreshedEvent event) { System.out.println("onApplicationEvent"); - //开启审计功能 + // 开启审计功能 AuditManager.setAuditEnable(true); - -//设置 SQL 审计收集器 - MessageCollector collector = new ConsoleMessageCollector(); + // 设置 SQL 审计收集器 + MessageCollector collector = new ConsoleMessageCollector((sql, tookTimeMillis) -> + System.out.println(SqlFormatter.format(sql))); AuditManager.setMessageCollector(collector); } diff --git a/mybatis-flex-test/pom.xml b/mybatis-flex-test/pom.xml index edbd985c..4a10d6c7 100644 --- a/mybatis-flex-test/pom.xml +++ b/mybatis-flex-test/pom.xml @@ -26,6 +26,14 @@ 8 + + + com.github.vertical-blank + sql-formatter + 2.0.4 + + +