Skip to content

ObjectProvider iterable/stream access for "beans of type" resolution in @Bean methods [SPR-11419] #16046

Closed
@spring-projects-issues

Description

@spring-projects-issues

Oliver Drotbohm opened SPR-11419 and commented

In JavaConfig you can currently use an @Autowired(required = false) List<MyComponent> myComponents field to access all beans of a given type to potentially hand them into a component manually instantiated in an @Bean method.

That said, it would be nice if this pattern could be used at the @Bean method level directly such as:

@Bean public MyOtherComponent foo(List<MyComponent> myComponents) {
  …
}

This currently throws an exception if not bean of type MyComponent can be found but could just fall back to an empty list, which is what you get with the field based approach currently.


Affects: 4.0.1

Issue Links:

0 votes, 5 watchers

Metadata

Metadata

Assignees

Labels

in: coreIssues in core modules (aop, beans, core, context, expression)type: enhancementA general enhancement

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions