Skip to content

Bean definition DSL does not generate unique bean names [SPR-17242] #21775

@spring-projects-issues

Description

@spring-projects-issues

Brian Clozel opened SPR-17242 and commented

When using the bean definition DSL, using the simplest variant of the DSL for defining beans like this creates issues:

val beans = beans {
    bean { fooRouter() } // defines a RouterFunction
    bean { 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?


Affects: 5.0.8

Reference URL: spring-projects/spring-boot#14295

Issue Links:

Referenced from: commits b6d32ef

Metadata

Metadata

Assignees

Labels

in: coreIssues in core modules (aop, beans, core, context, expression)type: enhancementA general enhancement

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions