打印SQL配置参数化
This commit is contained in:
parent
d09b65c396
commit
9f4991f32f
@ -18,6 +18,10 @@ spring:
|
||||
# 多久检查一次连接的活性
|
||||
keepaliveTime: 30000
|
||||
mybatis-flex:
|
||||
# sql审计
|
||||
audit_enable: true
|
||||
# sql打印
|
||||
sql_print: true
|
||||
datasource:
|
||||
# 数据源-1
|
||||
ds1:
|
||||
@ -113,3 +117,43 @@ powerjob:
|
||||
allow-lazy-connect-server: false
|
||||
max-appended-wf-context-length: 4096
|
||||
max-result-length: 4096
|
||||
|
||||
--- # sms 短信 支持 华为 阿里云 腾讯云 等等各式各样的短信服务商
|
||||
# https://sms4j.com/doc3/ 文档地址 各个厂商可同时使用
|
||||
sms:
|
||||
# 标注从yml读取配置
|
||||
config-type: yaml
|
||||
is-print: true
|
||||
blends:
|
||||
# 自定义的标识,也就是configId这里可以是任意值(最好不要是中文)
|
||||
tx1:
|
||||
#厂商标识,标定此配置是哪个厂商,详细请看厂商标识介绍部分
|
||||
supplier: tencent
|
||||
#您的accessKey
|
||||
access-key-id: 您的accessKey
|
||||
#您的accessKeySecret
|
||||
access-key-secret: 您的accessKeySecret
|
||||
#您的短信签名
|
||||
signature: 您的短信签名
|
||||
#模板ID 非必须配置,如果使用sendMessage的快速发送需此配置
|
||||
template-id: xxxxxxxx
|
||||
#短信自动重试间隔时间 默认五秒
|
||||
retry-interval: 5
|
||||
# 短信重试次数,默认0次不重试,如果你需要短信重试则根据自己的需求修改值即可
|
||||
max-retries: 0
|
||||
#您的sdkAppId
|
||||
sdk-app-id: 您的sdkAppId
|
||||
# 自定义的标识,也就是configId这里可以是任意值(最好不要是中文)
|
||||
tx2:
|
||||
#厂商标识,标定此配置是哪个厂商,详细请看厂商标识介绍部分
|
||||
supplier: tencent
|
||||
#您的accessKey
|
||||
access-key-id: 您的accessKey
|
||||
#您的accessKeySecret
|
||||
access-key-secret: 您的accessKeySecret
|
||||
#您的短信签名
|
||||
signature: 您的短信签名
|
||||
#模板ID 非必须配置,如果使用sendMessage的快速发送需此配置
|
||||
template-id: xxxxxxxx
|
||||
#您的sdkAppId
|
||||
sdk-app-id: 您的sdkAppId
|
||||
|
@ -18,6 +18,10 @@ spring:
|
||||
# 多久检查一次连接的活性
|
||||
keepaliveTime: 30000
|
||||
mybatis-flex:
|
||||
# sql审计
|
||||
audit_enable: false
|
||||
# sql打印
|
||||
sql_print: false
|
||||
datasource:
|
||||
# 数据源-1
|
||||
ds1:
|
||||
|
@ -134,7 +134,7 @@ mybatis-flex:
|
||||
# 关闭日志记录 org.apache.ibatis.logging.nologging.NoLoggingImpl
|
||||
# 默认日志输出 org.apache.ibatis.logging.slf4j.Slf4jImpl
|
||||
#log_impl: org.apache.ibatis.logging.stdout.StdOutImpl
|
||||
logImpl: org.apache.ibatis.logging.stdout.StdOutImpl
|
||||
logImpl: org.apache.ibatis.logging.nologging.NoLoggingImpl
|
||||
cacheEnabled: true
|
||||
global-config:
|
||||
# 是否控制台打印 MyBatis-Flex 的 LOGO 及版本号
|
||||
|
@ -3,6 +3,7 @@ package com.ruoyi.common.orm.config;
|
||||
import com.mybatisflex.core.FlexGlobalConfig;
|
||||
import com.mybatisflex.core.audit.AuditManager;
|
||||
import com.mybatisflex.core.audit.ConsoleMessageCollector;
|
||||
import com.mybatisflex.core.audit.MessageCollector;
|
||||
import com.mybatisflex.core.datasource.DataSourceDecipher;
|
||||
import com.mybatisflex.core.mybatis.FlexConfiguration;
|
||||
import com.mybatisflex.spring.boot.ConfigurationCustomizer;
|
||||
@ -12,11 +13,11 @@ import com.ruoyi.common.orm.decipher.Decipher;
|
||||
import com.ruoyi.common.orm.listener.EntityInsertListener;
|
||||
import com.ruoyi.common.orm.listener.EntityUpdateListener;
|
||||
import org.apache.ibatis.logging.stdout.StdOutImpl;
|
||||
import org.mybatis.spring.annotation.MapperScan;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
|
||||
|
||||
/**
|
||||
@ -29,6 +30,12 @@ public class MyBatisFlexConfig implements ConfigurationCustomizer, MyBatisFlexCu
|
||||
|
||||
private static final Logger logger = LoggerFactory.getLogger("mybatis-flex-sql");
|
||||
|
||||
@Value("${mybatis-flex.audit_enable}")
|
||||
private Boolean enableAudit = false;
|
||||
|
||||
@Value("${mybatis-flex.sql_print}")
|
||||
private Boolean sqlPrint = false;
|
||||
|
||||
/**
|
||||
* 数据源解密
|
||||
*/
|
||||
@ -40,9 +47,11 @@ public class MyBatisFlexConfig implements ConfigurationCustomizer, MyBatisFlexCu
|
||||
|
||||
@Override
|
||||
public void customize(FlexConfiguration configuration) {
|
||||
//mybatis实现的打印sql到控制台,便于调试
|
||||
//mybatis实现的打印详细sql及返回结果到控制台,便于调试
|
||||
if (sqlPrint) {
|
||||
configuration.setLogImpl(StdOutImpl.class);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Mybatis-Flex自定义初始化配置
|
||||
@ -56,10 +65,14 @@ public class MyBatisFlexConfig implements ConfigurationCustomizer, MyBatisFlexCu
|
||||
globalConfig.registerUpdateListener(new EntityUpdateListener(), BaseEntity.class);
|
||||
|
||||
// 开启审计功能
|
||||
AuditManager.setAuditEnable(enableAudit);
|
||||
if (sqlPrint) {
|
||||
// 开启sql打印默认会开启sql审计
|
||||
AuditManager.setAuditEnable(true);
|
||||
// AuditManager.setMessageFactory(new AuditMessageFactory());
|
||||
//设置 SQL 审计收集器
|
||||
AuditManager.setMessageCollector(new ConsoleMessageCollector());
|
||||
MessageCollector collector = new ConsoleMessageCollector();
|
||||
AuditManager.setMessageCollector(collector);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user