@@ -4593,15 +4593,16 @@ If you intend to express annotation-driven injection by name, do not primarily u
4593
4593
semantically defined to identify a specific target component by its unique name, with
4594
4594
the declared type being irrelevant for the matching process.
4595
4595
4596
- As a specific consequence of this semantic difference, beans that are themselves defined
4597
- as a collection or map type cannot be injected through `@Autowired`, because type
4598
- matching is not properly applicable to them. Use `@Resource` for such beans, referring
4599
- to the specific collection or map bean by unique name.
4596
+ For beans that are themselves defined as a collection/map or array type, `@Resource`
4597
+ is a fine solution, referring to the specific collection or array bean by unique name.
4598
+ That said, as of 4.3, collection/map and array types can be matched through Spring's
4599
+ `@Autowired` type matching algorithm as well, as long as the element type information
4600
+ is preserved in `@Bean` return type signatures or collection inheritance hierarchies.
4600
4601
4601
4602
`@Autowired` applies to fields, constructors, and multi-argument methods, allowing for
4602
4603
narrowing through qualifier annotations at the parameter level. By contrast, `@Resource`
4603
- is supported only for fields and bean property setter methods with a single argument. As
4604
- a consequence, stick with qualifiers if your injection target is a constructor or a
4604
+ is supported only for fields and bean property setter methods with a single argument.
4605
+ As a consequence, stick with qualifiers if your injection target is a constructor or a
4605
4606
multi-argument method.
4606
4607
====
4607
4608
0 commit comments