mirror of
https://gitee.com/mybatis-flex/mybatis-flex.git
synced 2025-12-07 00:58:24 +08:00
test: 添加 SQL 格式化输出。
This commit is contained in:
parent
ea37895c6a
commit
4e06242d06
@ -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;
|
||||
@ -52,9 +53,9 @@ public class SampleApplication implements CommandLineRunner, ApplicationListener
|
||||
System.out.println("onApplicationEvent");
|
||||
// 开启审计功能
|
||||
AuditManager.setAuditEnable(true);
|
||||
|
||||
// 设置 SQL 审计收集器
|
||||
MessageCollector collector = new ConsoleMessageCollector();
|
||||
MessageCollector collector = new ConsoleMessageCollector((sql, tookTimeMillis) ->
|
||||
System.out.println(SqlFormatter.format(sql)));
|
||||
AuditManager.setMessageCollector(collector);
|
||||
}
|
||||
|
||||
|
||||
@ -26,6 +26,14 @@
|
||||
<maven.compiler.target>8</maven.compiler.target>
|
||||
</properties>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>com.github.vertical-blank</groupId>
|
||||
<artifactId>sql-formatter</artifactId>
|
||||
<version>2.0.4</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
<build>
|
||||
<plugins>
|
||||
<plugin>
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user