-
Notifications
You must be signed in to change notification settings - Fork 38.5k
AutowireCapableBeanFactory.createBean does not prefer default constructor anymore #30041
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
Just to be clear: for us the main problem is that an extra bean is created, not that the wrong constructor is used (although I am sure the latter will be a problem also..) |
Understood. From the framework perspective, the root of the problem is the selection of a different constructor in the case of multiple public constructors, hence the change of title. I've applied a narrower algorithm now that selects a Kotlin primary / single public / single non-public constructor candidate, analogous to our constructor resolution convention for data/record classes, in addition to the default constructor. So in ambiguous scenarios with multiple constructors at the same level, we prefer the default constructor now rather than select by autowiring ability, while at the same time picking the obvious preferred constructor in other scenarios (analogous to This will be included in the 6.0.6 release tonight, hopefully addressing the common regression while also keeping the intention of #29855. In 6.1, we will eventually deprecate the overloaded |
Thanks, latest 6.0-SNAPSHOT seems to work again |
Uh oh!
There was an error while loading. Please reload this page.
With a project from
start.spring.io
.Expected output, as with version 6.0.4 / Spring Boot 3.0.2
Actual output with 6.0.5 / Spring Boot 3.0.3
The text was updated successfully, but these errors were encountered: