Add multiple datasource

This commit is contained in:
2023-12-11 18:32:48 +08:00
parent 06889d0fb1
commit 19d20a0f09
4 changed files with 21 additions and 7 deletions

View File

@@ -5,7 +5,7 @@
<parent> <parent>
<groupId>org.springframework.boot</groupId> <groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId> <artifactId>spring-boot-starter-parent</artifactId>
<version>3.2.0</version> <version>3.1.4</version>
<relativePath/> <!-- lookup parent from repository --> <relativePath/> <!-- lookup parent from repository -->
</parent> </parent>
<groupId>top.fatweb</groupId> <groupId>top.fatweb</groupId>
@@ -78,7 +78,7 @@
<kotlin.version>1.9.21</kotlin.version> <kotlin.version>1.9.21</kotlin.version>
<build.timestamp>${maven.build.timestamp}</build.timestamp> <build.timestamp>${maven.build.timestamp}</build.timestamp>
<maven.build.timestamp.format>yyyy-MM-dd'T'HH:mm:ss</maven.build.timestamp.format> <maven.build.timestamp.format>yyyy-MM-dd'T'HH:mm:ss</maven.build.timestamp.format>
<flyway.version>10.2.0</flyway.version> <flyway.version>9.22.3</flyway.version>
</properties> </properties>
<dependencies> <dependencies>
<dependency> <dependency>

View File

@@ -19,6 +19,9 @@ server:
spring: spring:
datasource: datasource:
dynamic:
datasource:
master:
url: jdbc:mysql://localhost # MySQL url url: jdbc:mysql://localhost # MySQL url
username: root # MySQL username username: root # MySQL username
password: root # MySQL password password: root # MySQL password

View File

@@ -7,8 +7,19 @@ spring:
profiles: profiles:
active: config active: config
datasource: datasource:
dynamic:
primary: master
strict: false
datasource:
master:
type: com.zaxxer.hikari.HikariDataSource type: com.zaxxer.hikari.HikariDataSource
driver-class-name: com.mysql.cj.jdbc.Driver driver-class-name: com.mysql.cj.jdbc.Driver
local:
type: com.zaxxer.hikari.HikariDataSource
driver-class-name: org.sqlite.JDBC
url: jdbc:sqlite::resource:db/sqlite.db
jackson: jackson:
date-format: yyyy-MM-dd'T'HH:mm:ss.SSS'Z' date-format: yyyy-MM-dd'T'HH:mm:ss.SSS'Z'
time-zone: GMT time-zone: GMT

View File