You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
GenericApplicationContext.registerBean should support non-default constructors [SPR-17292] #21825
While AnnotationConfigApplicationContext.registerBean supports @Autowired resolution on constructors in case of no instance supplier given, the original method on GenericApplicationContext performs default instantiation only. Making GenericApplicationContext.registerBean smarter in detecting a Kotlin primary constructor or simple non-default public constructor scenarios makes it aligned with AnnotationConfigApplicationContext and more useful in general, in particular for Kotlin DSLs.
Since full AUTOWIRE_CONSTRUCTOR exhaustively looks at all constructors (public, private, whatever), it does not seem like an ideal candidate here. Instead, a new "preferred constructors" mechanism allows registerBean to suggest the Kotlin primary constructor and standard public constructors to be evaluated for autowiring before falling back to default instantiation. This covers the intended use cases and is largely aligned with the constructor determination algorithm for model attribute processing.
Activity
spring-projects-issues commentedon Sep 19, 2018
Juergen Hoeller commented
Since full
AUTOWIRE_CONSTRUCTORexhaustively looks at all constructors (public, private, whatever), it does not seem like an ideal candidate here. Instead, a new "preferred constructors" mechanism allowsregisterBeanto suggest the Kotlin primary constructor and standard public constructors to be evaluated for autowiring before falling back to default instantiation. This covers the intended use cases and is largely aligned with the constructor determination algorithm for model attribute processing.spring-projects-issues commentedon Sep 19, 2018
Juergen Hoeller commented
Sébastien Deleuze, this should cover your intended use case in the Kotlin DSL now, with no need for a custom post-processor anymore.
spring-projects-issues commentedon Sep 19, 2018
Sébastien Deleuze commented
Thanks, I have updated the Kotlin DSL accordingly.