-
Notifications
You must be signed in to change notification settings - Fork 40.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Document limitations of new approach to configure multiple DataSources #43481
Comments
|
I'd like to prepare an PR if the team accept this solution, see https://github.com/spring-projects/spring-boot/compare/main...quaff:patch-108?expand=1. |
Before this commit, non default and autowire candidate DataSources are not applied. Closes spring-projectsGH-43481
I'm not a fan of using the |
I vote for new methods on |
The intent was for such general container lookups to happen via We could introduce new methods on |
Holding to the new year as we consider options |
The documentation for Spring Boot 3.4 now recommends the
@Qualifier("xyz")
and@Bean(defaultCandidate = false)
approach to define multipleDataSources
: https://docs.spring.io/spring-boot/3.4/how-to/data-access.html#howto.data-access.configure-two-datasourcesAt first glance, this approach is neat because the first
DataSource
is set up by auto-configuration as if there were no secondDataSource
. However, the new approach has some probably unwanted side-effects that users should be made aware of.With the previous approach (see https://docs.spring.io/spring-boot/3.3/how-to/data-access.html#howto.data-access.configure-two-datasources), the additional
DataSources
would still participate in other auto-configurations such asDataSourcePoolMetricsAutoConfiguration
andDataSourceHealthContributorAutoConfiguration
. That is no longer the case with the new approach, because an additionalDataSource
withdefaultCandidate = false
is neither present inMap<String, DataSource>
nor is it available viaObjectProvider<DataSource>
.I leave it to the subject matter experts to decide what should be done:
ObjectProvider<DataSource>
)—not sure if that is even possible or a good idea for that matterThe text was updated successfully, but these errors were encountered: