环境 - JBoss 5.1、Spring 3.1.2、jdk 1.5
我正在尝试自动装配列表。根据此处的讨论Auto-wiring a List using util schema 会给出 NoSuchBeanDefinitionException,@Resource 不适用于 JBoss。
<util:list id="reportTypes">
<value>PDF</value>
<value>CSV</value>
<value>XML</value>
</util:list>
@Inject
private List<String> reportTypes;
我也尝试过使用@Inject,但我得到了同样的异常。我错过了什么?
我正在为@Inject 使用 JSR 330,com.springsource.javax.inject-0.9.0.PFD.jar 文件,如此处所述http://forum.springsource.org/showthread.php?78737-JSR-330-Inject -春天-3-0
Caused by: 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.inject.Inject()}
编辑使用
@Resource(name = "reportTypes")
private List<String> reportTypes;
投掷
java.lang.RuntimeException: mapped-name is required for reportTypes of deployment app.war
at org.jboss.web.tomcat.service.injection.WebResourceHandler.loadXmlResourceEnvRefs(WebResourceHandler.java:287)
at org.jboss.web.tomcat.service.injection.WebResourceHandler.loadXml(WebResourceHandler.java:325)
at org.jboss.web.tomcat.service.TomcatInjectionContainer.processMetadata(TomcatInjectionContainer.java:550)
at org.jboss.web.tomcat.service.WebCtxLoader.start(WebCtxLoader.java:158)