From f9f025df433e7beca72fbe843296b8550b40d5a8 Mon Sep 17 00:00:00 2001 From: Juergen Hoeller Date: Tue, 8 Oct 2024 11:36:39 +0200 Subject: [PATCH] Add note on autowireCandidate versus defaultCandidate Closes gh-33392 --- .../beans/dependencies/factory-autowire.adoc | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/framework-docs/modules/ROOT/pages/core/beans/dependencies/factory-autowire.adoc b/framework-docs/modules/ROOT/pages/core/beans/dependencies/factory-autowire.adoc index 36d9a97502..fa7ba3de48 100644 --- a/framework-docs/modules/ROOT/pages/core/beans/dependencies/factory-autowire.adoc +++ b/framework-docs/modules/ROOT/pages/core/beans/dependencies/factory-autowire.adoc @@ -124,5 +124,21 @@ These techniques are useful for beans that you never want to be injected into ot by autowiring. It does not mean that an excluded bean cannot itself be configured by using autowiring. Rather, the bean itself is not a candidate for autowiring other beans. +[NOTE] +==== +As of 6.2, `@Bean` methods support two variants of the autowire candidate flag: +`autowireCandidate` and `defaultCandidate`. + +When using xref:core/beans/annotation-config/autowired-qualifiers.adoc[qualifiers], +a bean marked with `defaultCandidate=false` is only available for injection points +where an additional qualifier indication is present. This is useful for restricted +delegates that are supposed to be injectable in certain areas but are not meant to +get in the way of beans of the same type in other places. Such a bean will never +get injected by plain declared type only, rather by type plus specific qualifier. + +In contrast, `autowireCandidate=false` behaves exactly like the `autowire-candidate` +attribute as explained above: Such a bean will never get injected by type at all. +==== +