Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

修正连接池配置 #14

Open
wants to merge 3 commits into
base: dev-single
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,8 @@ protected void configure(HttpSecurity http) throws Exception {
"/api/**",
"/system/**",
"/v3/**",
"/swagger-ui/**"
"/swagger-ui/**",
"/druid/**"
).permitAll()
.anyRequest().authenticated()
.and()
Expand Down
28 changes: 21 additions & 7 deletions genshin-map-config/src/main/resources-dev/application-dev.yml
Original file line number Diff line number Diff line change
@@ -1,19 +1,33 @@
spring:
profiles:
include:
- common
- nacos-dev
- datasource-dev
datasource:
driver-class-name: com.mysql.cj.jdbc.Driver
type: com.alibaba.druid.pool.DruidDataSource
datasource:
druid:
# 初始连接数
initial-size: 8
#最大连接数
max-active: 20
# 最小保持连接数
min-idle: 8
async-init: false
########## 配置StatViewServlet(监控页面),用于展示Druid的统计信息 ##########
stat-view-servlet:
login-username: root # 配置监控页面访问密码
login-password: 123
reset-enable: false # 不允许清空统计数据,重新计算

logging:
level:
site:
yuanshen:
genshin:
@@ -21,4 +28,8 @@ logging:
core: debug
site.yuanshen.data.mapper: debug
# org.springframework:
data:
mapper: debug
org:
springframework:
# security: debug
# cache: debug
cache: debug
32 changes: 12 additions & 20 deletions genshin-map-config/src/main/resources-prod/application-prod.yml
Original file line number Diff line number Diff line change
@@ -1,29 +1,21 @@
spring:
profiles:
include:
- common
- nacos-prod
- datasource-prod
datasource:
driver-class-name: com.mysql.cj.jdbc.Driver
type: com.alibaba.druid.pool.DruidDataSource
datasource:
druid:
time-between-eviction-runs-millis: 10000
min-evictable-idle-time-millis: 30000
max-evictable-idle-time-millis: 7200000
validation-query-timeout: 3
validation-query: SELECT 1
test-on-borrow: false
test-on-return: false
test-while-idle: true
max-active: 20
max-pool-prepared-statement-per-connection-size: 20
initial-size: 2
max-wait: 6000
min-idle: 2
pool-prepared-statements: true
max-open-prepared-statements: 20
async-init: true
druid:
# 初始连接数
initial-size: 50
#最大连接数
max-active: 100
# 最小保持连接数
min-idle: 50
########## 配置StatViewServlet(监控页面),用于展示Druid的统计信息 ##########
stat-view-servlet:
enabled: true # 启用StatViewServlet
reset-enable: false # 清空统计数据

springdoc:
api-docs:
Expand Down
41 changes: 41 additions & 0 deletions genshin-map-config/src/main/resources/application-common.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
spring:
datasource:
driver-class-name: org.postgresql.Driver
type: com.alibaba.druid.pool.DruidDataSource
druid:
# 池中某个连接的空闲时长达到 N 毫秒后, 连接池在下次检查空闲连接时,将回收该连接
min-evictable-idle-time-millis: 300000
# 检测超时
validation-query-timeout: 1
validation-query: SELECT 1
# 申请连接时检测有效,影响性能
test-on-borrow: false
# 归还连接时检测有效,影响性能
test-on-return: false
# 循环检测有效,不影响性能
test-while-idle: true
# 检查空闲连接的频率,单位毫秒
time-between-eviction-runs-millis: 10000
# 是否缓存preparedStatement, mysql下关闭,支持游标的数据库开启
pool-prepared-statements: true
# 缓存preparedStatement大小,开启后建议100,-1关闭
max-pool-prepared-statement-per-connection-size: 100
async-init: false
filter:
# 开启druiddatasource的状态监控
stat:
enabled: true
db-type: postgresql
log-slow-sql: true
slow-sql-millis: 1000
connection-stack-trace-enable: true
########## 配置WebStatFilter,用于采集web关联监控的数据 ##########
web-stat-filter:
enabled: true # 启动 StatFilter
url-pattern: /* # 过滤所有url
exclusions: "*.js,*.gif,*.jpg,*.png,*.css,*.ico,/druid/*" # 排除一些不必要的url
session-stat-enable: false # 开启session统计功能
########## 配置StatViewServlet(监控页面),用于展示Druid的统计信息 ##########
stat-view-servlet:
enabled: true # 启用StatViewServlet
reset-enable: true # 不允许清空统计数据,重新计算
Empty file.