Spring依赖注入:注入所有接口实例 [英] Spring dependency injection: Inject all instances of interface
本文介绍了Spring依赖注入:注入所有接口实例的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
如果可能的话,我如何使用实现特定接口的所有其他Spring bean的集合来配置Spring bean?
How, if possible can I configure a Spring bean with all a collection of other Spring beans that implements a specific interface?
示例:我想将 CarFactory
bean与实现的bean列表连接起来CarManufacturer
界面。
Example: I want to wire the CarFactory
bean with a list of beans implementing the CarManufacturer
interface.
推荐答案
@Inject
private List<CarManufacturer> manufacturers;
这篇关于Spring依赖注入:注入所有接口实例的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文