|
57 | 57 | * return obj; |
58 | 58 | * }</pre> |
59 | 59 | * |
60 | | - * <h3>Profile, Scope, Lazy, DependsOn, Primary, Order</h3> |
| 60 | + * <h3>Profile, Scope, Lazy, DependsOn, Primary, Fallback, Order</h3> |
61 | 61 | * |
62 | 62 | * <p>Note that the {@code @Bean} annotation does not provide attributes for profile, |
63 | | - * scope, lazy, depends-on or primary. Rather, it should be used in conjunction with |
64 | | - * {@link Scope @Scope}, {@link Lazy @Lazy}, {@link DependsOn @DependsOn} and |
| 63 | + * scope, lazy, depends-on, or primary. Rather, it should be used in conjunction with |
| 64 | + * {@link Scope @Scope}, {@link Lazy @Lazy}, {@link DependsOn @DependsOn}, and |
65 | 65 | * {@link Primary @Primary} annotations to declare those semantics. For example: |
66 | 66 | * |
67 | 67 | * <pre class="code"> |
|
82 | 82 | * through direct references, which is typically helpful for singleton startup. |
83 | 83 | * {@code @Primary} is a mechanism to resolve ambiguity at the injection point level |
84 | 84 | * if a single target component needs to be injected but several beans match by type. |
| 85 | + * {@code @Fallback} marks a bean as a fallback candidate in such scenarios; if all |
| 86 | + * beans but one among multiple matching candidates are marked as fallback, the |
| 87 | + * remaining bean will be selected. |
85 | 88 | * |
86 | 89 | * <p>Additionally, {@code @Bean} methods may also declare qualifier annotations |
87 | 90 | * and {@link org.springframework.core.annotation.Order @Order} values, to be |
|
97 | 100 | * orthogonal concern determined by dependency relationships and {@code @DependsOn} |
98 | 101 | * declarations as mentioned above. Also, {@link jakarta.annotation.Priority} is not |
99 | 102 | * available at this level since it cannot be declared on methods; its semantics can |
100 | | - * be modeled through {@code @Order} values in combination with {@code @Primary} on |
101 | | - * a single bean per type. |
| 103 | + * be modeled through {@code @Order} values in combination with {@code @Primary} or |
| 104 | + * {@code @Fallback} on a single bean per type. |
102 | 105 | * |
103 | 106 | * <h3>{@code @Bean} Methods in {@code @Configuration} Classes</h3> |
104 | 107 | * |
|
230 | 233 | * @see DependsOn |
231 | 234 | * @see Lazy |
232 | 235 | * @see Primary |
| 236 | + * @see Fallback |
233 | 237 | * @see org.springframework.stereotype.Component |
234 | 238 | * @see org.springframework.beans.factory.annotation.Autowired |
235 | 239 | * @see org.springframework.beans.factory.annotation.Value |
|
0 commit comments