-
Notifications
You must be signed in to change notification settings - Fork 38.8k
Closed
Closed
Copy link
Labels
in: coreIssues in core modules (aop, beans, core, context, expression)Issues in core modules (aop, beans, core, context, expression)type: bugA general bugA general bug
Milestone
Description
Jeffrey Sinclair opened SPR-6463 and commented
When I try to override a constructor arg by name in a child bean definition an exception arises which does not arise when I override the constructor arg by index.
I could be mistaken but I see this as a bug because if I can inherit by name and override by index, then I should also be able to override by name.
Specifically I've created an abstract bean definition as follows:
<bean id="abstractPerson" abstract="true">
<constructor-arg value="Jeff Sinclair" name="name" />
</bean>
I've then tried to create a concrete bean definition by overriding the named constructor arg:
<bean id="concretePerson" class="test.spring.Person"
parent="abstractPerson">
<constructor-arg value="Jeff S Sinclair" name="name" />
</bean>
This throws the following exception:
Exception in thread "main" org.springframework.beans.factory.BeanCreationException:
Error creating bean with name 'concretePerson' defined in class path resource [test/spring/applicationContext.xml]:
2 constructor arguments specified but no matching constructor found in bean 'concretePerson'
(hint:specify index/type/name arguments for simple parameters to avoid type ambiguities)
at
org.springframework.beans.factory.support.ConstructorResolver.autowireConstructor(ConstructorResolver.java:171)
...
at test.spring.Main.main(Main.java:9)
Affects: 3.0 RC2
Issue Links:
- Bean Configuration Overriding [SPR-5509] #10181 Bean Configuration Overriding
- Document constructor-arg 'name' attribute [SPR-7443] #12101 Document constructor-arg 'name' attribute
Referenced from: commits 666700f
Metadata
Metadata
Assignees
Labels
in: coreIssues in core modules (aop, beans, core, context, expression)Issues in core modules (aop, beans, core, context, expression)type: bugA general bugA general bug