我写了一个项目,并在那里使用了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发布于 2021-03-18 07:48:25
据我所知,您只能使用一个数据源。但是您可以在配置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来决定使用哪一个。这个样本工程为您提供了一个很好的源代码。
https://stackoverflow.com/questions/66685475
复制相似问题