-
Notifications
You must be signed in to change notification settings - Fork 40.5k
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
@ConditionalOnBean matches beans that are not autowire candidates resulting in UnsatisfiedDependencyException when an attempt is made to inject the bean #41526
Comments
Thanks for the report. This appears to be a more general problem and is not specific to
There's a mismatch between At this point, Spring Boot's auto-configuration isn't compatible with |
@alexey-anufriev what's your use case for an |
My case is very close to my initially reported code, I have a |
We discussed this today and we consider this a bug, but one that is quite risky to fix before 3.4. We're considering adding some additional attribute to the |
Do you have in mind how will this work? Will the new default behavior be a breaking change? I mean, for now, non-candidates are skipped by default. Will I be required to consider those, or will I be required to exclude those? |
We're not yet certain and we'd like to do some experimentation. Right now, I think it's likely that it will be a breaking change and we'll start ignoring non-autowire candidates by default when looking for matching beans. We'll have to wait and see though. |
It should be backported since |
We think it's a bit risky for a backport since it's a change in behavior. |
It's a bug fix, I can't imagine which user case would rely the buggy behavior. |
It's also the risk of regression due to unexpected or accidental side-effects. Given that the problem has existed with XML config for Boot's entire life and with Java config since Boot 2.1 yet it was only reported for the first time last month, I see no need to back port the fix and risk destabilising maintenance branches. |
Assuming the following test:
And having
spring-boot-starter-actuator
andmicrometer-core
in dependencies the test fails with:Reproducer: https://github.com/alexey-anufriev/autowire-candidate-error
The text was updated successfully, but these errors were encountered: