Skip to content

Commit f9f025d

Browse files
committed
Add note on autowireCandidate versus defaultCandidate
Closes gh-33392
1 parent 1eee795 commit f9f025d

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

framework-docs/modules/ROOT/pages/core/beans/dependencies/factory-autowire.adoc

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -124,5 +124,21 @@ These techniques are useful for beans that you never want to be injected into ot
124124
by autowiring. It does not mean that an excluded bean cannot itself be configured by
125125
using autowiring. Rather, the bean itself is not a candidate for autowiring other beans.
126126

127+
[NOTE]
128+
====
129+
As of 6.2, `@Bean` methods support two variants of the autowire candidate flag:
130+
`autowireCandidate` and `defaultCandidate`.
131+
132+
When using xref:core/beans/annotation-config/autowired-qualifiers.adoc[qualifiers],
133+
a bean marked with `defaultCandidate=false` is only available for injection points
134+
where an additional qualifier indication is present. This is useful for restricted
135+
delegates that are supposed to be injectable in certain areas but are not meant to
136+
get in the way of beans of the same type in other places. Such a bean will never
137+
get injected by plain declared type only, rather by type plus specific qualifier.
138+
139+
In contrast, `autowireCandidate=false` behaves exactly like the `autowire-candidate`
140+
attribute as explained above: Such a bean will never get injected by type at all.
141+
====
142+
127143

128144

0 commit comments

Comments
 (0)