支持多数据源

This commit is contained in:
阿沐 2023-06-16 11:11:14 +08:00
parent 19cf33648e
commit e71f06c89d
3 changed files with 78 additions and 52 deletions

View File

@ -7,27 +7,29 @@ spring:
#password: #password:
#timeout: 6000ms # 连接超时时长(毫秒) #timeout: 6000ms # 连接超时时长(毫秒)
datasource: datasource:
# MySQL8 dynamic:
driver-class-name: com.mysql.cj.jdbc.Driver hikari: # Hikari 连接池全局配置
url: jdbc:mysql://localhost:3306/maku_boot?useUnicode=true&characterEncoding=UTF-8&serverTimezone=Asia/Shanghai&nullCatalogMeansCurrent=true connection-timeout: 30000 # 等待连接池分配链接的最大时长(毫秒),超过这个时长还没有可用的连接则发生 SQLException默认30 秒
username: maku minimum-idle: 2 # 最小空闲连接数
password: 123456 maximum-pool-size: 10 # 最大连接数
# 达梦 idle-timeout: 600000 # 连接超时的最大时长毫秒超时则被释放retired默认10 分钟
# driver-class-name: dm.jdbc.driver.DmDriver max-lifetime: 1800000 # 连接的生命时长毫秒超时而且没被使用则被释放retired默认 30 分钟
# url: jdbc:dm://192.168.3.19:5236/maku_boot?useUnicode=true&characterEncoding=UTF-8&serverTimezone=Asia/Shanghai&nullCatalogMeansCurrent=true connection-test-query: SELECT 1
# username: maku_boot primary: master
# password: 12345678 datasource:
# PostgreSQL master:
# driver-class-name: org.postgresql.Driver # MySQL8
# url: jdbc:postgresql://192.168.3.19:5432/postgres driver-class-name: com.mysql.cj.jdbc.Driver
# username: postgres url: jdbc:mysql://localhost:3306/maku_boot?useUnicode=true&characterEncoding=UTF-8&serverTimezone=Asia/Shanghai&nullCatalogMeansCurrent=true
# password: 123456 username: maku
hikari: password: 123456
connection-timeout: 30000 # 等待连接池分配链接的最大时长(毫秒),超过这个时长还没有可用的连接则发生 SQLException默认30 秒 # 达梦
minimum-idle: 2 # 最小空闲连接数 # driver-class-name: dm.jdbc.driver.DmDriver
maximum-pool-size: 10 # 最大连接数 # url: jdbc:dm://192.168.3.19:5236/maku_boot?useUnicode=true&characterEncoding=UTF-8&serverTimezone=Asia/Shanghai&nullCatalogMeansCurrent=true
auto-commit: true # 自动提交 # username: maku_boot
idle-timeout: 600000 # 连接超时的最大时长毫秒超时则被释放retired默认10 分钟 # password: 12345678
max-lifetime: 1800000 # 连接的生命时长毫秒超时而且没被使用则被释放retired默认 30 分钟 # PostgreSQL
connection-test-query: SELECT 1 # driver-class-name: org.postgresql.Driver
pool-name: MakuHikariCP # url: jdbc:postgresql://192.168.3.19:5432/postgres
# username: postgres
# password: 123456

View File

@ -7,17 +7,29 @@ spring:
#password: #password:
#timeout: 6000ms # 连接超时时长(毫秒) #timeout: 6000ms # 连接超时时长(毫秒)
datasource: datasource:
type: com.zaxxer.hikari.HikariDataSource dynamic:
driver-class-name: com.mysql.cj.jdbc.Driver hikari: # Hikari 连接池全局配置
url: jdbc:mysql://localhost:3306/maku_boot?useUnicode=true&characterEncoding=UTF-8&serverTimezone=Asia/Shanghai&nullCatalogMeansCurrent=true connection-timeout: 30000 # 等待连接池分配链接的最大时长(毫秒),超过这个时长还没有可用的连接则发生 SQLException默认30 秒
username: maku minimum-idle: 2 # 最小空闲连接数
password: 123456 maximum-pool-size: 10 # 最大连接数
hikari: idle-timeout: 600000 # 连接超时的最大时长毫秒超时则被释放retired默认10 分钟
connection-timeout: 30000 # 等待连接池分配链接的最大时长(毫秒),超过这个时长还没有可用的连接则发生 SQLException默认30 秒 max-lifetime: 1800000 # 连接的生命时长毫秒超时而且没被使用则被释放retired默认 30 分钟
minimum-idle: 2 # 最小空闲连接数 connection-test-query: SELECT 1
maximum-pool-size: 10 # 最大连接数 primary: master
auto-commit: true # 自动提交 datasource:
idle-timeout: 600000 # 连接超时的最大时长毫秒超时则被释放retired默认10 分钟 master:
max-lifetime: 1800000 # 连接的生命时长毫秒超时而且没被使用则被释放retired默认 30 分钟 # MySQL8
connection-test-query: SELECT 1 driver-class-name: com.mysql.cj.jdbc.Driver
pool-name: MakuHikariCP url: jdbc:mysql://localhost:3306/maku_boot?useUnicode=true&characterEncoding=UTF-8&serverTimezone=Asia/Shanghai&nullCatalogMeansCurrent=true
username: maku
password: 123456
# 达梦
# driver-class-name: dm.jdbc.driver.DmDriver
# url: jdbc:dm://192.168.3.19:5236/maku_boot?useUnicode=true&characterEncoding=UTF-8&serverTimezone=Asia/Shanghai&nullCatalogMeansCurrent=true
# username: maku_boot
# password: 12345678
# PostgreSQL
# driver-class-name: org.postgresql.Driver
# url: jdbc:postgresql://192.168.3.19:5432/postgres
# username: postgres
# password: 123456

View File

@ -7,17 +7,29 @@ spring:
#password: #password:
#timeout: 6000ms # 连接超时时长(毫秒) #timeout: 6000ms # 连接超时时长(毫秒)
datasource: datasource:
type: com.zaxxer.hikari.HikariDataSource dynamic:
driver-class-name: com.mysql.cj.jdbc.Driver hikari: # Hikari 连接池全局配置
url: jdbc:mysql://localhost:3306/maku_boot?useUnicode=true&characterEncoding=UTF-8&serverTimezone=Asia/Shanghai&nullCatalogMeansCurrent=true connection-timeout: 30000 # 等待连接池分配链接的最大时长(毫秒),超过这个时长还没有可用的连接则发生 SQLException默认30 秒
username: maku minimum-idle: 2 # 最小空闲连接数
password: 123456 maximum-pool-size: 10 # 最大连接数
hikari: idle-timeout: 600000 # 连接超时的最大时长毫秒超时则被释放retired默认10 分钟
connection-timeout: 30000 # 等待连接池分配链接的最大时长(毫秒),超过这个时长还没有可用的连接则发生 SQLException默认30 秒 max-lifetime: 1800000 # 连接的生命时长毫秒超时而且没被使用则被释放retired默认 30 分钟
minimum-idle: 2 # 最小空闲连接数 connection-test-query: SELECT 1
maximum-pool-size: 10 # 最大连接数 primary: master
auto-commit: true # 自动提交 datasource:
idle-timeout: 600000 # 连接超时的最大时长毫秒超时则被释放retired默认10 分钟 master:
max-lifetime: 1800000 # 连接的生命时长毫秒超时而且没被使用则被释放retired默认 30 分钟 # MySQL8
connection-test-query: SELECT 1 driver-class-name: com.mysql.cj.jdbc.Driver
pool-name: MakuHikariCP url: jdbc:mysql://localhost:3306/maku_boot?useUnicode=true&characterEncoding=UTF-8&serverTimezone=Asia/Shanghai&nullCatalogMeansCurrent=true
username: maku
password: 123456
# 达梦
# driver-class-name: dm.jdbc.driver.DmDriver
# url: jdbc:dm://192.168.3.19:5236/maku_boot?useUnicode=true&characterEncoding=UTF-8&serverTimezone=Asia/Shanghai&nullCatalogMeansCurrent=true
# username: maku_boot
# password: 12345678
# PostgreSQL
# driver-class-name: org.postgresql.Driver
# url: jdbc:postgresql://192.168.3.19:5432/postgres
# username: postgres
# password: 123456