1
我嘗試注入到六月試運行與基於SpringJUnit4ClassRunner這個bean:如何自動裝配util:list?
<util:list id="MyList" value-type="java.lang.String">
<value>val1</value>
<value>val2</value>
<value>val3</value>
</util:list>
在測試用例對MyTestCase: @Resource(mappedName = 「MYLIST」) @Qualifier( 「MYLIST」) 私有列表myList中;
但總是收到異常: 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)}
什麼能是什麼原因? 謝謝。
您能解釋爲什麼@Autowired @Qualifier(「MyList」)失敗,但@Resource(「MyList」)的工作原理? – 2015-11-24 13:44:24