I'm looking for a way to use multiple ConnectionFactory beans in my reactive Spring Boot app. Looking at the autoconfigurations everything is package private, with hardcoded properties paths and not allowing multiple connection factory beans.
More precisely, I need a reusable form of org.springframework.boot.autoconfigure.r2dbc.ConnectionFactoryConfigurations allowing for multiple ConnectionFactory beans. This is already available for data sources as described here - https://www.baeldung.com/spring-boot-configure-multiple-datasources.
As a workaround, I'm disabling R2dbcAutoconfiguration and enabling my own declared in package org.springframework.boot.autoconfigure.r2dbc so I can use some of the methods in ConnectionFactoryConfigurations. I'm not seeing any better way of handling this right now (aside from copying Spring's sources).
Comment From: philwebb
You're looking for something similar to https://docs.spring.io/spring-boot/docs/current/reference/htmlsingle/#howto.data-access.configure-two-datasources but with R2DBC?
Comment From: GeorgiPetkov
You're looking for something similar to https://docs.spring.io/spring-boot/docs/current/reference/htmlsingle/#howto.data-access.configure-two-datasources but with R2DBC?
Exactly! Doesn't have to be the same approach in terms of design, but the goal is the same.
Comment From: d-sch
Hello.
I found an nice and easy workaround using mostly what is already provided using basically a Map<String, org.springframework.boot.autoconfigure.r2dbc.R2dbcProperties.
https://d-sch.github.io/posts/enable-multiple-r2dcb-connection-factories/