@@ -154,17 +154,19 @@ Letting qualifier values select against target bean names, within the type-match
154
154
candidates, does not require a `@Qualifier` annotation at the injection point.
155
155
If there is no other resolution indicator (such as a qualifier or a primary marker),
156
156
for a non-unique dependency situation, Spring matches the injection point name
157
- (that is, the field name or parameter name) against the target bean names and chooses the
158
- same-named candidate, if any.
157
+ (that is, the field name or parameter name) against the target bean names and chooses
158
+ the same-named candidate, if any (either by bean name or by associated alias) .
159
159
160
160
Since version 6.1, this requires the `-parameters` Java compiler flag to be present.
161
+ As of 6.2, the container applies fast shortcut resolution for bean name matches,
162
+ bypassing the full type matching algorithm when the parameter name matches the
163
+ bean name and no type, qualifier or primary conditions override the match. It is
164
+ therefore recommendable for your parameter names to match the target bean names.
161
165
====
162
166
163
- That said, if you intend to express annotation-driven injection by name, do not
164
- primarily use `@Autowired`, even if it is capable of selecting by bean name among
165
- type-matching candidates. Instead, use the JSR-250 `@Resource` annotation, which is
166
- semantically defined to identify a specific target component by its unique name, with
167
- the declared type being irrelevant for the matching process. `@Autowired` has rather
167
+ As an alternative for injection by name, consider the JSR-250 `@Resource` annotation
168
+ which is semantically defined to identify a specific target component by its unique name,
169
+ with the declared type being irrelevant for the matching process. `@Autowired` has rather
168
170
different semantics: After selecting candidate beans by type, the specified `String`
169
171
qualifier value is considered within those type-selected candidates only (for example,
170
172
matching an `account` qualifier against beans marked with the same qualifier label).
0 commit comments