Skip to content

Commit 3696c2f

Browse files
author
zhengjie
committed
优化 druid 连接池,启动类添加@EnableAsync注解,开启Spring boot 异步支持
1 parent 9494601 commit 3696c2f

File tree

3 files changed

+26
-31
lines changed

3 files changed

+26
-31
lines changed

eladmin-system/src/main/java/me/zhengjie/AppRun.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,15 @@
44
import org.springframework.boot.SpringApplication;
55
import org.springframework.boot.autoconfigure.SpringBootApplication;
66
import org.springframework.context.annotation.Bean;
7+
import org.springframework.scheduling.annotation.EnableAsync;
78
import org.springframework.transaction.annotation.EnableTransactionManagement;
89
import org.springframework.web.socket.config.annotation.EnableWebSocketMessageBroker;
910

1011
/**
1112
* @author jie
1213
* @date 2018/11/15 9:20:19
1314
*/
15+
@EnableAsync
1416
@SpringBootApplication
1517
@EnableTransactionManagement
1618
@EnableWebSocketMessageBroker

eladmin-system/src/main/resources/config/application-dev.yml

Lines changed: 12 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -8,27 +8,23 @@ spring:
88
username: root
99
password: 123456
1010

11-
# 初始化连接大小
12-
initial-size: 5
13-
# 最小空闲连接数
14-
min-idle: 5
15-
max-active: 20
16-
max-wait: 30000
17-
# 可关闭的空闲连接间隔时间
18-
time-between-eviction-runs-millis: 60000
19-
# 配置连接在池中的最小生存时间
20-
min-evictable-idle-time-millis: 300000
21-
validation-query: select '1' from dual
11+
# 初始化配置
12+
initial-size: 3
13+
# 最小连接数
14+
min-idle: 3
15+
# 最大连接数
16+
max-active: 15
17+
# 获取连接超时时间
18+
max-wait: 5000
19+
# 连接有效性检测时间
20+
time-between-eviction-runs-millis: 90000
21+
# 最大空闲时间
22+
min-evictable-idle-time-millis: 1800000
2223
test-while-idle: true
2324
test-on-borrow: false
2425
test-on-return: false
25-
# 打开PSCache,并且指定每个连接上PSCache的大小
26-
pool-prepared-statements: true
27-
max-open-prepared-statements: 20
28-
max-pool-prepared-statement-per-connection-size: 20
2926
# 配置监控统计拦截的filters
3027
filters: stat
31-
3228
stat-view-servlet:
3329
url-pattern: /druid/*
3430
reset-enable: false

eladmin-system/src/main/resources/config/application-prod.yml

Lines changed: 12 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -8,24 +8,21 @@ spring:
88
username: root
99
password: 123456
1010

11-
# 初始化连接大小
12-
initial-size: 5
13-
# 最小空闲连接数
14-
min-idle: 5
15-
max-active: 20
16-
max-wait: 30000
17-
# 可关闭的空闲连接间隔时间
18-
time-between-eviction-runs-millis: 60000
19-
# 配置连接在池中的最小生存时间
20-
min-evictable-idle-time-millis: 300000
21-
validation-query: select '1' from dual
11+
# 初始化配置
12+
initial-size: 3
13+
# 最小连接数
14+
min-idle: 3
15+
# 最大连接数
16+
max-active: 15
17+
# 获取连接超时时间
18+
max-wait: 5000
19+
# 连接有效性检测时间
20+
time-between-eviction-runs-millis: 90000
21+
# 最大空闲时间
22+
min-evictable-idle-time-millis: 1800000
2223
test-while-idle: true
2324
test-on-borrow: false
2425
test-on-return: false
25-
# 打开PSCache,并且指定每个连接上PSCache的大小
26-
pool-prepared-statements: true
27-
max-open-prepared-statements: 20
28-
max-pool-prepared-statement-per-connection-size: 20
2926
# 配置监控统计拦截的filters
3027
filters: stat
3128

0 commit comments

Comments
 (0)