-
Notifications
You must be signed in to change notification settings - Fork 41.2k
Metrics and health do not include non-default candidate beans #43481
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
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 |
This issue is now blocked by spring-projects/spring-framework#34203. If implemented we'd hopefully be able to restore the previous behavior with such beans. |
This comment has been minimized.
This comment has been minimized.
Before this commit, non default and autowire candidate DataSources are not applied. Closes spring-projectsGH-43481 Signed-off-by: Yanming Zhou <zhouyanming@gmail.com>
This comment has been minimized.
This comment has been minimized.
@wilkinsona Thanks for fixing this! I think you forgot to adapt |
See spring-projects#43481 (comment) Signed-off-by: Yanming Zhou <zhouyanming@gmail.com>
You are right, I'd like to create PR if @wilkinsona think https://github.com/spring-projects/spring-boot/compare/main...quaff:patch-108?expand=1 is correct fix. |
See spring-projects#43481 (comment) Signed-off-by: Yanming Zhou <zhouyanming@gmail.com>
Well spotted, @mdaepp. Thank you. @quaff, that change to the main code looks good to me, thank you. On the testing side, rather than adding a new test, I'd change @Configuration(proxyBeanMethods = false)
static class MultipleHikariDataSourcesConfiguration {
@Bean
DataSource standardDataSource() {
return createHikariDataSource("standardDataSource");
}
@Bean(defaultCandidate = false)
DataSource nonDefault() {
return createHikariDataSource("nonDefault");
}
@Bean(autowireCandidate = false)
DataSource nonAutowire() {
return createHikariDataSource("nonAutowire");
}
} And then adapt the tests that used |
See spring-projects#43481 (comment) Signed-off-by: Yanming Zhou <zhouyanming@gmail.com>
See spring-projects#43481 (comment) Signed-off-by: Yanming Zhou <zhouyanming@gmail.com>
See #43481 (comment) See gh-44253 Signed-off-by: Yanming Zhou <zhouyanming@gmail.com>
Uh oh!
There was an error while loading. Please reload this page.
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: