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
Bean definition DSL does not generate unique bean names [SPR-17242] #21775
When using the bean definition DSL, using the simplest variant of the DSL for defining beans like this creates issues:
valbeans = beans {
bean { fooRouter() } // defines a RouterFunctionbean { barRouter() } // defines a RouterFunction
}
If no bean name is provided by the bean registration DSL call, GenericApplicationContext.registerBean will register it by default with the bean class name, which means that it's easy to override another definition, and impossible to define multiple beans of the same type without manually defining bean names.
Could we add other strategies that fall back on default bean names, to be more in line with the annotation/XML models? Could we try and derive that information from other parts of the DSL?
We're calling BeanDefinitionReaderUtils.uniqueBeanName for turning the class name into a unique bean name now: through appending a counter as suffix, similar to XML bean definitions.
Activity
spring-projects-issues commentedon Sep 7, 2018
Sébastien Deleuze commented
+1 for generating unique bean names, I faced this issue multiple times in Kotlin functional web applications and Spring Fu.
spring-projects-issues commentedon Sep 12, 2018
Juergen Hoeller commented
We're calling
BeanDefinitionReaderUtils.uniqueBeanNamefor turning the class name into a unique bean name now: through appending a counter as suffix, similar to XML bean definitions.