- 
                Notifications
    You must be signed in to change notification settings 
- Fork 38.8k
Closed
Labels
status: declinedA suggestion or change that we don't feel we should currently applyA suggestion or change that we don't feel we should currently apply
Description
Christian Hersevoort opened SPR-14179 and commented
The case is as follows:
Beans:
- MyParentBean
- MyChildBeanA implements MyChildBean
- MyChildBeanB implements MyChildBean
XML configuration:
<bean id="myChildBeanA" class="com.hersevoort.java.test.MyChildBeanA">
</bean>
<bean id="myChildBeanB" class="com.hersevoort.java.test.MyChildBeanB">
</bean>
<bean id="myParentBean" class="com.hersevoort.java.test.MyParentBean">
	<property name="myChild" ref="myChildBeanB"/>
</bean>Case #1: This works:
public class MyParentBean
{
	private MyChildBean myChild;
	@Inject
	public void setMyChild(MyChildBean myChild)
	{
		this.myChild = myChild;
	}
}Case #2: This doesn't work:
public class MyParentBean
{
	@Inject
	private MyChildBean myChild;
}I expect Spring to handle both cases exactly the same, but Case #2 throws an unexpected NoUniqueBeanDefinitionException. (see attachment)
Am I wrong to assume this is a bug?
Affects: 4.2.1, 4.2.5, 4.3 RC1
Attachments:
- stacktrace.txt (7.43 kB)
Issue Links:
- Should @Configuration mark @Inject fields and setters as satisfied (injected)? [SPR-14180] #18751 Should @Configurationmark@Injectfields and setters as satisfied (injected)?
Metadata
Metadata
Assignees
Labels
status: declinedA suggestion or change that we don't feel we should currently applyA suggestion or change that we don't feel we should currently apply