Is there a way in Spring to autowire all dependencies of a given type?

前端 未结 2 1764
北海茫月
北海茫月 2020-12-16 20:29

I\'m using annotations-based wiring (ie @Configurable(autowire=Autowire.BY_TYPE)) for a given class, and I\'d like to wire all beans of a given type into it as

2条回答
  •  没有蜡笔的小新
    2020-12-16 21:07

    Yes,

    @Inject
    private List configurers;
    

    works, and you get a list of all beans implementing the interface. (multiple variations - @Inject or @Autowired, field, setter or constructor injection - all work)

提交回复
热议问题