Skip to content

Allow @Bean to override a dynamically registered bean definition [SPR-10607] #15236

@spring-projects-issues

Description

@spring-projects-issues

Dave Syer opened SPR-10607 and commented

ConfigurationClassBeanDefinitionReader does not allow a @Bean to override anything that is not itself a @Bean:

if (!(existingBeanDef instanceof ConfigurationClassBeanDefinition)) {
// no -> then it's an external override, probably XML
// overriding is legal, return immediately
...

The assumption that non-@Beans come from XML is false, since they can be (and increasingly are) registered by an import selector or similar piece of framework machinery. In any case this seems like an arbitrary rule (XML beans are just as valid to override as any other). All users really need is some predictability about the bean definition load order, so they can reason about what should override what.


Affects: 4.0 M1

Issue Links:

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