Skip to content

Commit a6d56a0

Browse files
committed
update datasource config
1 parent 1d828d6 commit a6d56a0

2 files changed

Lines changed: 61 additions & 31 deletions

File tree

.idea/workspace.xml

Lines changed: 14 additions & 14 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/main/resources/application.yml

Lines changed: 47 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ logging:
2424
org.hibernate.SQL: WARN
2525
org.hibernate.type.descriptor.sql.BasicBinder: WARN
2626
org.postgresql: WARN
27-
com.zaxxer.hikari: WARN
27+
com.zaxxer.hikari: DEBUG
2828
# 其他框架日志
2929
springfox: WARN
3030

@@ -65,35 +65,65 @@ spring:
6565
driver-class-name: com.mysql.cj.jdbc.Driver
6666

6767
hikari:
68-
idle-timeout: 30000
69-
max-lifetime: 1800000
70-
connection-timeout: 30000
7168
pool-name: SupabasePool
72-
maximum-pool-size: 20
73-
minimum-idle: 10
74-
data-source-properties:
75-
preparedStatementCacheQueries: 0
76-
preparedStatementCacheSizeMiB: 0
77-
prepareThreshold: 0
69+
maximum-pool-size: 8
70+
minimum-idle: 2
71+
connection-timeout: 10000 # 连接超时10秒
72+
idle-timeout: 300000 # 空闲超时5分钟(300秒)
73+
max-lifetime: 900000 # 连接生命周期15分钟
74+
leak-detection-threshold: 30000 # 泄漏检测30秒
75+
validation-timeout: 5000 # 验证超时5秒
76+
connection-test-query: SELECT 1 # 添加验证查询
77+
# 优化事务设置
78+
transaction-isolation: TRANSACTION_READ_COMMITTED
79+
# 自动提交设置为false(使用事务管理)
80+
auto-commit: false
81+
# 连接池统计
82+
register-mbeans: true
7883

7984
jpa:
8085
properties:
8186
hibernate:
82-
temp:
83-
use_jdbc_metadata_defaults: false
87+
# 批处理优化
8488
order_inserts: true
8589
order_updates: true
8690
jdbc:
8791
batch_size: 50
88-
lob:
89-
non_contextual_creation: true
92+
batch_versioned_data: true
93+
# 事务优化
94+
transaction:
95+
jta:
96+
platform: com.atomikos.icatch.jta.hibernate4.AtomikosPlatform
97+
# 连接释放策略
98+
connection:
99+
release_mode: after_transaction
100+
# 防止内存泄漏
101+
generate_statistics: false
102+
temp:
103+
use_jdbc_metadata_defaults: false
90104
bytecode:
91105
provider: bytebuddy
92106
format_sql: true
107+
# 查询超时设置
108+
javax:
109+
persistence:
110+
query:
111+
timeout: 20000 # 查询超时20秒
93112
database-platform: org.hibernate.dialect.PostgreSQLDialect
94113
hibernate:
95114
ddl-auto: validate
96115
show-sql: false
116+
# # 开启二级缓存(可选)
117+
# properties:
118+
# hibernate:
119+
# cache:
120+
# use_second_level_cache: false
121+
# use_query_cache: false
122+
123+
# 事务管理配置
124+
transaction:
125+
default-timeout: 30 # 默认事务超时30秒
126+
rollback-on-commit-failure: true
97127

98128
# E-mail (QQ 邮箱配置)
99129
mail:
@@ -118,9 +148,9 @@ spring:
118148
connect-timeout: 5000
119149
lettuce:
120150
pool:
121-
max-active: 20
122-
max-idle: 10
123-
min-idle: 5
151+
max-active: 10 # Redis连接池也相应减小
152+
max-idle: 5
153+
min-idle: 2
124154
max-wait: 3000ms
125155
shutdown-timeout: 100ms
126156

0 commit comments

Comments
 (0)