Clarify primary/fallback autowiring for arrays/collections/maps

Closes gh-32301
This commit is contained in:
Juergen Hoeller
2024-02-21 20:24:57 +01:00
parent f5397d6426
commit f811f0dc18
3 changed files with 84 additions and 27 deletions

View File

@@ -29,6 +29,11 @@ import java.lang.annotation.Target;
* <p>If all beans but one among multiple matching candidates are marked
* as a fallback, the remaining bean will be selected.
*
* <p>Just like primary beans, fallback beans only have an effect when
* finding multiple candidates for single injection points.
* All type-matching beans are included when autowiring arrays,
* collections, maps, or ObjectProvider streams.
*
* @author Juergen Hoeller
* @since 6.2
* @see Primary

View File

@@ -27,6 +27,10 @@ import java.lang.annotation.Target;
* are qualified to autowire a single-valued dependency. If exactly one
* 'primary' bean exists among the candidates, it will be the autowired value.
*
* <p>Primary beans only have an effect when finding multiple candidates
* for single injection points. All type-matching beans are included when
* autowiring arrays, collections, maps, or ObjectProvider streams.
*
* <p>This annotation is semantically equivalent to the {@code <bean>} element's
* {@code primary} attribute in Spring XML.
*