Java 多个数据 Jdbc 和 R2dbc 问题
Java multiple data Jdbc and R2dbc problem
我写了一个项目,我在那里使用了 r2dbc 和 jdbc。现在数据库有问题。我怎样才能把它们分开?信息来了却报错
Operator called default onErrorDropped
Application.yml
spring:
liquibase:
enabled: true
url: jdbc:postgresql://localhost:5432/liquebase
user: postgres
password: 12345
change-log: classpath:db/liquibase/db.changelog-master-main.yml
datasource:
driver-class-name: org.postgresql.Driver
hikari:
minimum-idle: 5
r2dbc:
url: r2dbc:postgresql://127.0.0.1:5432/liquebase
username: postgres
password: 12345
pool:
initial-size: 100
max-size: 500
max-idle-time: 30m
validation-query: SELECT 1
server:
port: 8085
据我所知,您只能使用一个数据源。但是你可以在配置 application.yml
上配置两者并在它们之间切换。像这样:
spring:
profiles:
active: dev00
---
spring:
config:
activate:
on-profile: dev00
liquibase:
enabled: true
url: jdbc:postgresql://localhost:5432/liquebase
user: postgres
password: 12345
change-log: classpath:db/liquibase/db.changelog-master-main.yml
datasource:
driver-class-name: org.postgresql.Driver
hikari:
minimum-idle: 5
server:
port: 8085
---
spring:
config:
activate:
on-profile: dev01
r2dbc:
url: r2dbc:postgresql://127.0.0.1:5432/liquebase
username: postgres
password: 12345
pool:
initial-size: 100
max-size: 500
max-idle-time: 30m
validation-query: SELECT 1
server:
port: 8085
然后您通过配置spring.profiles.active: dev00
或spring.profiles.active: dev01
来决定使用哪一个。这个sample project给你一个很好的源代码。
我写了一个项目,我在那里使用了 r2dbc 和 jdbc。现在数据库有问题。我怎样才能把它们分开?信息来了却报错
Operator called default onErrorDropped
Application.yml
spring:
liquibase:
enabled: true
url: jdbc:postgresql://localhost:5432/liquebase
user: postgres
password: 12345
change-log: classpath:db/liquibase/db.changelog-master-main.yml
datasource:
driver-class-name: org.postgresql.Driver
hikari:
minimum-idle: 5
r2dbc:
url: r2dbc:postgresql://127.0.0.1:5432/liquebase
username: postgres
password: 12345
pool:
initial-size: 100
max-size: 500
max-idle-time: 30m
validation-query: SELECT 1
server:
port: 8085
据我所知,您只能使用一个数据源。但是你可以在配置 application.yml
上配置两者并在它们之间切换。像这样:
spring:
profiles:
active: dev00
---
spring:
config:
activate:
on-profile: dev00
liquibase:
enabled: true
url: jdbc:postgresql://localhost:5432/liquebase
user: postgres
password: 12345
change-log: classpath:db/liquibase/db.changelog-master-main.yml
datasource:
driver-class-name: org.postgresql.Driver
hikari:
minimum-idle: 5
server:
port: 8085
---
spring:
config:
activate:
on-profile: dev01
r2dbc:
url: r2dbc:postgresql://127.0.0.1:5432/liquebase
username: postgres
password: 12345
pool:
initial-size: 100
max-size: 500
max-idle-time: 30m
validation-query: SELECT 1
server:
port: 8085
然后您通过配置spring.profiles.active: dev00
或spring.profiles.active: dev01
来决定使用哪一个。这个sample project给你一个很好的源代码。