perf(dataSource): 优化数据源配置和初始化过程
- 添加 Druid 过滤器配置,启用慢 SQL 记录和多语句允许 - 更新日志配置,优化日志输出级别 - 重构数据源创建逻辑,简化初始化过程
This commit is contained in:
parent
e981c462ec
commit
2686e4b47a
@ -69,6 +69,16 @@ spring:
|
|||||||
login-password: 123456 # 密码
|
login-password: 123456 # 密码
|
||||||
allow: "" # IP白名单 (没有配置或者为空,则允许所有访问)
|
allow: "" # IP白名单 (没有配置或者为空,则允许所有访问)
|
||||||
deny: "" # IP黑名单 (存在共同时,deny优先于allow)
|
deny: "" # IP黑名单 (存在共同时,deny优先于allow)
|
||||||
|
filter:
|
||||||
|
stat:
|
||||||
|
enabled: true
|
||||||
|
# 慢SQL记录
|
||||||
|
log-slow-sql: true
|
||||||
|
slow-sql-millis: 1000
|
||||||
|
merge-sql: true
|
||||||
|
wall:
|
||||||
|
config:
|
||||||
|
multi-statement-allow: true
|
||||||
|
|
||||||
# 是否开启分布式事务,如不开启,请删除atomikos插件,否则atomikos相关驱动虽不生效但仍会启动
|
# 是否开启分布式事务,如不开启,请删除atomikos插件,否则atomikos相关驱动虽不生效但仍会启动
|
||||||
atomikos:
|
atomikos:
|
||||||
|
@ -14,7 +14,7 @@ ruoyi:
|
|||||||
captchaType: math
|
captchaType: math
|
||||||
# 指定默认文件服务类型(值为disk代表使用磁盘作为文件操作服务,minio代表使用minio作为文件操作服务,oss代表使用oss作为文件操作服务)
|
# 指定默认文件服务类型(值为disk代表使用磁盘作为文件操作服务,minio代表使用minio作为文件操作服务,oss代表使用oss作为文件操作服务)
|
||||||
fileServer: disk
|
fileServer: disk
|
||||||
# 指定默认文件上传方法最大文件大小
|
# 指定默认文件上传方法最大文件大小(MB)
|
||||||
fileMaxSize: 50
|
fileMaxSize: 50
|
||||||
|
|
||||||
# 开发环境配置
|
# 开发环境配置
|
||||||
@ -38,8 +38,13 @@ server:
|
|||||||
# 日志配置
|
# 日志配置
|
||||||
logging:
|
logging:
|
||||||
level:
|
level:
|
||||||
com.ruoyi: debug
|
"[com.ruoyi]": DEBUG
|
||||||
org.springframework: warn
|
"[org]": WARN
|
||||||
|
"[org.springframework]": WARN
|
||||||
|
"[org.apache]": WARN
|
||||||
|
"[org.springframework.context.support.PostProcessorRegistrationDelegate]": ERROR
|
||||||
|
"[com.alibaba.druid.spring.boot3.autoconfigure.stat.DruidSpringAopConfiguration]": ERROR
|
||||||
|
"[com.alibaba.druid.spring.boot3.autoconfigure.properties.DruidStatProperties]": ERROR
|
||||||
|
|
||||||
# 用户配置
|
# 用户配置
|
||||||
user:
|
user:
|
||||||
@ -51,6 +56,7 @@ user:
|
|||||||
ip:
|
ip:
|
||||||
maxRetryCount: 15
|
maxRetryCount: 15
|
||||||
lockTime: 15
|
lockTime: 15
|
||||||
|
|
||||||
# Spring配置
|
# Spring配置
|
||||||
spring:
|
spring:
|
||||||
cache:
|
cache:
|
||||||
|
@ -23,19 +23,11 @@ public class DataSourceCreate implements CreateDataSource {
|
|||||||
private DruidConfig druidConfig;
|
private DruidConfig druidConfig;
|
||||||
|
|
||||||
public DataSource createDataSource(String name, Properties prop) {
|
public DataSource createDataSource(String name, Properties prop) {
|
||||||
|
// DruidXADataSource dataSource = new DruidXADataSource();
|
||||||
DruidDataSource dataSource = new DruidDataSource();
|
DruidDataSource dataSource = new DruidDataSource();
|
||||||
druidConfig.getDruidDataSources().add(dataSource);
|
druidConfig.getDruidDataSources().add(dataSource);
|
||||||
|
|
||||||
// 设置基础属性
|
|
||||||
dataSource.setConnectProperties(prop);
|
dataSource.setConnectProperties(prop);
|
||||||
properties.setProperties(dataSource, prop);
|
properties.setProperties(dataSource, prop);
|
||||||
|
|
||||||
try {
|
|
||||||
dataSource.init();
|
|
||||||
} catch (Exception e) {
|
|
||||||
throw new RuntimeException("初始化数据源失败", e);
|
|
||||||
}
|
|
||||||
|
|
||||||
return dataSource;
|
return dataSource;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user