-
Notifications
You must be signed in to change notification settings - Fork 41.1k
Cyclic bean definition when a Spring Data repository is a dependency of a MeterBinder #27591
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
Comments
Thanks for the report, @joshiste. The cycle is due to the introduction of metrics for Spring Data repositories. You can break it in your own code by making @Bean
MeterBinder userMetrics(@Lazy UserService userService) {
return registry -> Gauge.builder("user.cout", userService::count);
} We'll have to see if there's something we can do in Spring Boot to make this unnecessary. If there isn't, we can at least update the documentation with some additional guidance. |
We can break the cycle in Boot by annotating the |
We discussed this today and we're going to change the |
I'm using a
MeterBinder
as suggested by the docs to register a gauge.While this worked perfectly fine on Spring Boot 2.4.9 it results in a bean definition cycle with 2.5.3,
Minimal project to reproduce the issue:
https://github.com/joshiste/issues/tree/boot-meterbinder
My Bean definitions:
The text was updated successfully, but these errors were encountered: