perf(dataSource): 优化数据源配置和初始化过程
- 添加 Druid 过滤器配置,启用慢 SQL 记录和多语句允许 - 更新日志配置,优化日志输出级别 - 重构数据源创建逻辑,简化初始化过程
This commit is contained in:
parent
e981c462ec
commit
2686e4b47a
@ -69,6 +69,16 @@ spring:
|
||||
login-password: 123456 # 密码
|
||||
allow: "" # IP白名单 (没有配置或者为空,则允许所有访问)
|
||||
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:
|
||||
|
@ -14,7 +14,7 @@ ruoyi:
|
||||
captchaType: math
|
||||
# 指定默认文件服务类型(值为disk代表使用磁盘作为文件操作服务,minio代表使用minio作为文件操作服务,oss代表使用oss作为文件操作服务)
|
||||
fileServer: disk
|
||||
# 指定默认文件上传方法最大文件大小
|
||||
# 指定默认文件上传方法最大文件大小(MB)
|
||||
fileMaxSize: 50
|
||||
|
||||
# 开发环境配置
|
||||
@ -38,8 +38,13 @@ server:
|
||||
# 日志配置
|
||||
logging:
|
||||
level:
|
||||
com.ruoyi: debug
|
||||
org.springframework: warn
|
||||
"[com.ruoyi]": DEBUG
|
||||
"[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:
|
||||
@ -51,6 +56,7 @@ user:
|
||||
ip:
|
||||
maxRetryCount: 15
|
||||
lockTime: 15
|
||||
|
||||
# Spring配置
|
||||
spring:
|
||||
cache:
|
||||
|
@ -23,19 +23,11 @@ public class DataSourceCreate implements CreateDataSource {
|
||||
private DruidConfig druidConfig;
|
||||
|
||||
public DataSource createDataSource(String name, Properties prop) {
|
||||
// DruidXADataSource dataSource = new DruidXADataSource();
|
||||
DruidDataSource dataSource = new DruidDataSource();
|
||||
druidConfig.getDruidDataSources().add(dataSource);
|
||||
|
||||
// 设置基础属性
|
||||
dataSource.setConnectProperties(prop);
|
||||
properties.setProperties(dataSource, prop);
|
||||
|
||||
try {
|
||||
dataSource.init();
|
||||
} catch (Exception e) {
|
||||
throw new RuntimeException("初始化数据源失败", e);
|
||||
}
|
||||
|
||||
return dataSource;
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user