配置文件修改

表映射配置 放在application.yml
This commit is contained in:
wangw 2025-01-02 10:00:02 +08:00
parent 78bf1c8c01
commit 003db71b7c
7 changed files with 130 additions and 156 deletions

View File

@ -49,22 +49,11 @@ public class ShardingConfig {
*/
private String centerTablesDataNode;
@Value("${center-tables}")
private String tableNamesAsString;
/**
* 中心表,不进行分库操作
*/
// @Value("${center-tables}")
private Set<String> centerTables;
@PostConstruct
public void init() {
// 使用换行符进行分割然后去除空白字符收集到Set集合中
centerTables = Arrays.stream(tableNamesAsString.split(","))
.map(String::trim)
.collect(Collectors.toSet());
}
private List<String> centerTables;
/**

View File

@ -1,84 +0,0 @@
# 数据源的一些配置
driver-class-name: com.mysql.cj.jdbc.Driver
# 最小空闲连接默认值10小于0或大于maximum-pool-size都会重置为maximum-pool-size
minimum-idle: 5
# 最大连接数小于等于0会被重置为默认值10大于零小于1会被重置为minimum-idle的值
maximum-pool-size: 15
# 空闲连接超时时间默认值60000010分钟大于等于max-lifetime且max-lifetime>0会被重置为0不等于0且小于10秒会被重置为10秒。
idle-timeout: 30000
# 连接最大存活时间.不等于0且小于30秒会被重置为默认值30分钟.设置应该比mysql设置的超时时间短
max-lifetime: 30000
# 连接超时时间:毫秒小于250毫秒否则被重置为默认值30秒
connection-timeout: 30000
spring:
# sharding-jdbc 配置
shardingsphere:
center-tables-data-node: duanju.%s
# 显示sharding-jdbc改写的sql语句
show-sql: false
# 数据源名称
datasource:
# 数据源配置begin
master-0:
driver-class-name: ${driver-class-name}
jdbc-url: jdbc:mysql://rm-gc7xx913734hv5w5q.mysql.cn-chengdu.rds.aliyuncs.com/duanju?useUnicode=true&characterEncoding=utf-8&useSSL=false&serverTimezone=CTT
# jdbc-url: jdbc:mysql://rm-gc7xx913734hv5w5qxo.mysql.cn-chengdu.rds.aliyuncs.com/duanju?useUnicode=true&characterEncoding=utf-8&useSSL=false&serverTimezone=CTT
username: video_user
password: VideoUser@1
minimum-idle: ${minimum-idle}
maximum-pool-size: ${maximum-pool-size}
idle-timeout: ${idle-timeout}
max-lifetime: ${max-lifetime}
connection-timeout: ${connection-timeout}
slave-0:
driver-class-name: ${driver-class-name}
jdbc-url: jdbc:mysql://localhost:3306/duanju?useUnicode=true&characterEncoding=utf-8&useSSL=false&serverTimezone=CTT
# jdbc-url: jdbc:mysql://47.122.73.144:3306/duanju?useUnicode=true&characterEncoding=utf-8&useSSL=false&serverTimezone=CTT
username: root
password: acddb0c84a192ada
minimum-idle: ${minimum-idle}
maximum-pool-size: ${maximum-pool-size}
idle-timeout: ${idle-timeout}
max-lifetime: ${max-lifetime}
connection-timeout: ${connection-timeout}
slave-1:
driver-class-name: ${driver-class-name}
jdbc-url: jdbc:mysql://172.18.96.9:3306/duanju?useUnicode=true&characterEncoding=utf-8&useSSL=false&serverTimezone=CTT
# jdbc-url: jdbc:mysql://47.122.30.120:3306/duanju?useUnicode=true&characterEncoding=utf-8&useSSL=false&serverTimezone=CTT
username: root
password: VideoUser1@
minimum-idle: ${minimum-idle}
maximum-pool-size: ${maximum-pool-size}
idle-timeout: ${idle-timeout}
max-lifetime: ${max-lifetime}
connection-timeout: ${connection-timeout}
slave-2:
driver-class-name: ${driver-class-name}
jdbc-url: jdbc:mysql://172.18.96.8:3306/duanju?useUnicode=true&characterEncoding=utf-8&useSSL=false&serverTimezone=CTT
# jdbc-url: jdbc:mysql://47.122.74.162:3306/duanju?useUnicode=true&characterEncoding=utf-8&useSSL=false&serverTimezone=CTT
username: root
password: VideoUser1@
minimum-idle: ${minimum-idle}
maximum-pool-size: ${maximum-pool-size}
idle-timeout: ${idle-timeout}
max-lifetime: ${max-lifetime}
connection-timeout: ${connection-timeout}
# 数据源配置end
# 读写分离配置begin
master-slave-rules:
#数据源
duanju:
master-data-source-name: master-0
slave-data-source-names: slave-0,slave-1,slave-2
# - slave-0
# - slave-1
# - slave-2
swagger:
enabled: false
pay:
h5BaseUrl: https://dj-h5.hnsiyao.cn/me/detail/detail?allId=
orderNotifyUrl: https://pay.hnsiyao.cn/czg/app/wuyou/notify
extractNotifyUrl: https://pay.hnsiyao.cn/czg/app/wuyou/extractNotify

View File

@ -1,3 +1,10 @@
swagger:
enabled: true
pay:
h5BaseUrl: https://video-h5.hnsiyao.cn/me/detail/detail?allId=
orderNotifyUrl: https://video.hnsiyao.cn/czg/app/wuyou/notify
extractNotifyUrl: https://video.hnsiyao.cn/czg/app/wuyou/extractNotify
# 数据源的一些配置
driver-class-name: com.mysql.cj.jdbc.Driver
# 最小空闲连接默认值10小于0或大于maximum-pool-size都会重置为maximum-pool-size
@ -50,10 +57,3 @@ spring:
slave-data-source-names: slave-0
# - master-0
# - slave-0
swagger:
enabled: true
pay:
h5BaseUrl: https://video-h5.hnsiyao.cn/me/detail/detail?allId=
orderNotifyUrl: https://video.hnsiyao.cn/czg/app/wuyou/notify
extractNotifyUrl: https://video.hnsiyao.cn/czg/app/wuyou/extractNotify

View File

@ -1,3 +1,10 @@
swagger:
enabled: true
pay:
h5BaseUrl: https://video-h5.hnsiyao.cn/me/detail/detail?allId=
orderNotifyUrl: https://video.hnsiyao.cn/czg/app/wuyou/notify
extractNotifyUrl: https://video.hnsiyao.cn/czg/app/wuyou/extractNotify
# 数据源的一些配置
driver-class-name: com.mysql.cj.jdbc.Driver
# 最小空闲连接默认值10小于0或大于maximum-pool-size都会重置为maximum-pool-size
@ -47,13 +54,5 @@ spring:
#数据源
duanju:
master-data-source-name: master-0
slave-data-source-names: slave-0
# - master-0
# - slave-0
swagger:
enabled: true
pay:
h5BaseUrl: https://video-h5.hnsiyao.cn/me/detail/detail?allId=
orderNotifyUrl: https://video.hnsiyao.cn/czg/app/wuyou/notify
extractNotifyUrl: https://video.hnsiyao.cn/czg/app/wuyou/extractNotify
slave-data-source-names:
- slave-0

View File

@ -1,3 +1,10 @@
swagger:
enabled: false
pay:
h5BaseUrl: https://dj-h5.hnsiyao.cn/me/detail/detail?allId=
orderNotifyUrl: https://pay.hnsiyao.cn/czg/app/wuyou/notify
extractNotifyUrl: https://pay.hnsiyao.cn/czg/app/wuyou/extractNotify
# 数据源的一些配置
driver-class-name: com.mysql.cj.jdbc.Driver
# 最小空闲连接默认值10小于0或大于maximum-pool-size都会重置为maximum-pool-size
@ -71,10 +78,3 @@ spring:
# - slave-0
# - slave-1
# - slave-2
swagger:
enabled: false
pay:
h5BaseUrl: https://dj-h5.hnsiyao.cn/me/detail/detail?allId=
orderNotifyUrl: https://pay.hnsiyao.cn/czg/app/wuyou/notify
extractNotifyUrl: https://pay.hnsiyao.cn/czg/app/wuyou/extractNotify

View File

@ -1 +0,0 @@
center-tables=activity,app,banner,cash_out,comment_good,common_info,complet_award,coupon,coupon_user,course,course_classification,course_collect,course_comment,course_details,course_user,disc_spinning,disc_spinning_amount,disc_spinning_record,help_classify,help_word,invite,invite_award,invite_money,message_info,msg,orders,pay_classify,pay_details,qrtz_blob_triggers,qrtz_calendars,qrtz_cron_triggers,qrtz_fired_triggers,qrtz_job_details,qrtz_locks,qrtz_paused_trigger_grps,qrtz_scheduler_state,qrtz_simple_triggers,qrtz_simprop_triggers,qrtz_triggers,schedule_job,schedule_job_log,sdk_info,sdk_type,search,sys_captcha,sys_config,sys_dict,sys_log,sys_menu,sys_oss,sys_role,sys_role_menu,sys_user,sys_user_role,sys_user_token,task_center,task_center_record,task_center_reward,tb_user,uni_ad_callback_record,url_address,user_integral,user_integral_details,user_money,user_money_details,user_prize_exchange,user_sign_record,user_vip,vip_details,invite_achievement

View File

@ -14,41 +14,6 @@ server:
servlet:
context-path: /czg
spring:
main:
allow-circular-references: true
allow-bean-definition-overriding: true
# 环境 dev|test|prod
profiles:
active: dev
# jackson时间格式化
jackson:
time-zone: GMT+8
date-format: yyyy-MM-dd HH:mm:ss
servlet:
multipart:
max-file-size: 10240MB
max-request-size: 10240MB
enabled: true
redis:
open: true # 是否开启redis缓存 true开启 false关闭
database: 0
host: localhost
port: 6379
password: 111111 # 密码(默认为空)
timeout: 6000ms # 连接超时时长(毫秒)
jedis:
pool:
max-active: 1000 # 连接池最大连接数(使用负值表示没有限制)
max-wait: -1ms # 连接池最大阻塞等待时间(使用负值表示没有限制)
max-idle: 10 # 连接池中的最大空闲连接
min-idle: 5 # 连接池中的最小空闲连接
mvc:
throw-exception-if-no-handler-found: true
# pathmatch:
# matching-strategy: ant_path_matcher
management:
health:
db:
@ -93,3 +58,109 @@ sqx:
limit:
urlRate: 10 # 同一用户单url每秒限制次数
ipJumpLimit: 4 # 同一ip每分钟跳动次数
spring:
main:
allow-circular-references: true
allow-bean-definition-overriding: true
# 环境 dev|test|prod
profiles:
active: local
# jackson时间格式化
jackson:
time-zone: GMT+8
date-format: yyyy-MM-dd HH:mm:ss
servlet:
multipart:
max-file-size: 10240MB
max-request-size: 10240MB
enabled: true
redis:
open: true # 是否开启redis缓存 true开启 false关闭
database: 0
host: localhost
port: 6379
password: 111111 # 密码(默认为空)
timeout: 6000ms # 连接超时时长(毫秒)
jedis:
pool:
max-active: 1000 # 连接池最大连接数(使用负值表示没有限制)
max-wait: -1ms # 连接池最大阻塞等待时间(使用负值表示没有限制)
max-idle: 10 # 连接池中的最大空闲连接
min-idle: 5 # 连接池中的最小空闲连接
mvc:
throw-exception-if-no-handler-found: true
# pathmatch:
# matching-strategy: ant_path_matcher
shardingsphere:
center-tables:
- activity
- app
- banner
- cash_out
- comment_good
- common_info
- complet_award
- coupon
- coupon_user
- course
- course_classification
- course_collect
- course_comment
- course_details
- course_user
- disc_spinning
- disc_spinning_amount
- disc_spinning_record
- help_classify
- help_word
- invite
- invite_award
- invite_money
- message_info
- msg
- orders
- pay_classify
- pay_details
- qrtz_blob_triggers
- qrtz_calendars
- qrtz_cron_triggers
- qrtz_fired_triggers
- qrtz_job_details
- qrtz_locks
- qrtz_paused_trigger_grps
- qrtz_scheduler_state
- qrtz_simple_triggers
- qrtz_simprop_triggers
- qrtz_triggers
- schedule_job
- schedule_job_log
- sdk_info
- sdk_type
- search
- sys_captcha
- sys_config
- sys_dict
- sys_log
- sys_menu
- sys_oss
- sys_role
- sys_role_menu
- sys_user
- sys_user_role
- sys_user_token
- task_center
- task_center_record
- task_center_reward
- tb_user
- uni_ad_callback_record
- url_address
- user_integral
- user_integral_details
- user_money
- user_money_details
- user_prize_exchange
- user_sign_record
- user_vip
- vip_details
- invite_achievement