我有一个ServiceListFactoryBean,它创建一个服务实现列表:
<bean id="services"
class="org.springframework.beans...ServiceListFactoryBean"
p:serviceType="ServiceInterface"/>
Run Code Online (Sandbox Code Playgroud)
我可以使用applicationContext访问服务而不会出现问题:
final List services = ctx.getBean("services", List.class));
Run Code Online (Sandbox Code Playgroud)
我也可以成功使用trad constructor-arg注入:
<bean id="aClass" class="AClass">
<constructor-arg ref="services"/>
</bean>
Run Code Online (Sandbox Code Playgroud)
但是,如果我尝试自动依赖
@Autowired @Qualifier("services") private List services;
Run Code Online (Sandbox Code Playgroud)
然后我得到一个BeanCreationException引起的
FatalBeanException: No element type declared for collection [java.util.List]
Run Code Online (Sandbox Code Playgroud)
我使用的是Spring 3.0.
Pau*_*zie 10
事实证明答案是......
@Resource(name="services") private List services;
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
13148 次 |
| 最近记录: |