Skip to content

Commit

Permalink
Clarify the behaviour of @Bean(autowireCandidate=false)
Browse files Browse the repository at this point in the history
  • Loading branch information
quaff committed Dec 11, 2024
1 parent 11db31a commit 2086886
Showing 1 changed file with 10 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;

import org.springframework.beans.factory.config.ConfigurableListableBeanFactory;
import org.springframework.beans.factory.support.AbstractBeanDefinition;
import org.springframework.core.annotation.AliasFor;

Expand Down Expand Up @@ -202,6 +203,7 @@
* @author Chris Beams
* @author Juergen Hoeller
* @author Sam Brannen
* @author Yanming Zhou
* @since 3.0
* @see Configuration
* @see Scope
Expand Down Expand Up @@ -242,6 +244,10 @@
* Is this bean a candidate for getting autowired into some other bean at all?
* <p>Default is {@code true}; set this to {@code false} for internal delegates
* that are not meant to get in the way of beans of the same type in other places.
* <p>NOTE: if this is set to {@code false}, bean is excluded when autowiring
* arrays, collections, maps, or ObjectProvider streams, use
* {@link ConfigurableListableBeanFactory#getBeansOfType(Class)}
* if you want to get all beans of the same type.
* @since 5.1
* @see #defaultCandidate()
*/
Expand All @@ -253,6 +259,10 @@
* <p>Default is {@code true}; set this to {@code false} 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.
* <p>NOTE: if this is set to {@code false}, bean is excluded when autowiring
* arrays, collections, maps, or ObjectProvider streams, use
* {@link ConfigurableListableBeanFactory#getBeansOfType(Class)}
* if you want to get all beans of the same type.
* <p>This is a variation of {@link #autowireCandidate()} which does not disable
* injection in general, just enforces an additional indication such as a qualifier.
* @since 6.2
Expand Down

0 comments on commit 2086886

Please sign in to comment.