Skip to content

Commit

Permalink
优化 druid 连接池,启动类添加@EnableAsync注解,开启Spring boot 异步支持
Browse files Browse the repository at this point in the history
  • Loading branch information
zhengjie committed Jun 2, 2019
1 parent 9494601 commit 3696c2f
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 31 deletions.
2 changes: 2 additions & 0 deletions eladmin-system/src/main/java/me/zhengjie/AppRun.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,15 @@
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.annotation.Bean;
import org.springframework.scheduling.annotation.EnableAsync;
import org.springframework.transaction.annotation.EnableTransactionManagement;
import org.springframework.web.socket.config.annotation.EnableWebSocketMessageBroker;

/**
* @author jie
* @date 2018/11/15 9:20:19
*/
@EnableAsync
@SpringBootApplication
@EnableTransactionManagement
@EnableWebSocketMessageBroker
Expand Down
28 changes: 12 additions & 16 deletions eladmin-system/src/main/resources/config/application-dev.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,27 +8,23 @@ spring:
username: root
password: 123456

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

stat-view-servlet:
url-pattern: /druid/*
reset-enable: false
Expand Down
27 changes: 12 additions & 15 deletions eladmin-system/src/main/resources/config/application-prod.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,24 +8,21 @@ spring:
username: root
password: 123456

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

Expand Down

0 comments on commit 3696c2f

Please sign in to comment.