I try to inject into juni test run with SpringJUnit4ClassRunner this bean:
<util:list id="MyList" value-type="java.lang.String">
<value>val1</value>
<value>val2</value>
<value>val3</value>
</util:list>
In test case MyTestCase:
@Resource (mappedName=”MyList”)
@Qualifier(“MyList”)
private List myList;
But always receive exception:
org.springframework.beans.factory.BeanCreationException:
Error creating bean MyTestCase
...................
org.springframework.beans.factory.NoSuchBeanDefinitionException: No matching bean
of type [java.lang.String] found for dependency [collection of
java.lang.String]: expected at least 1 bean which qualifies as autowire candidate
for this dependency.
Dependency annotations: {@javax.annotation.Resource(shareable=true,
mappedName=, description=, name=,
type=class java.lang.Object,
authenticationType=CONTAINER),
org.springframework.beans.factory.annotation.Qualifier(value=MyList)}
What can be the reason?
Thanks.
If it doesn’t work, set the
nameof the bean. The@Qualifierannotation works if you’ve used<qualifier>