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