Skip to content

Commit fc0ea46

Browse files
committed
Clarify expectations for getBean call with provided arguments
Closes gh-24955
1 parent 459338f commit fc0ea46

File tree

2 files changed

+5
-5
lines changed

2 files changed

+5
-5
lines changed

spring-beans/src/main/java/org/springframework/beans/factory/BeanFactory.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -170,6 +170,8 @@ public interface BeanFactory {
170170
* Return an instance, which may be shared or independent, of the specified bean.
171171
* <p>Allows for specifying explicit constructor arguments / factory method arguments,
172172
* overriding the specified default arguments (if any) in the bean definition.
173+
* Note that the provided arguments need to match a specific candidate constructor /
174+
* factory method in the order of declared parameters.
173175
* @param name the name of the bean to retrieve
174176
* @param args arguments to use when creating a bean instance using explicit arguments
175177
* (only applied when creating a new instance as opposed to retrieving an existing one)
@@ -202,6 +204,8 @@ public interface BeanFactory {
202204
* Return an instance, which may be shared or independent, of the specified bean.
203205
* <p>Allows for specifying explicit constructor arguments / factory method arguments,
204206
* overriding the specified default arguments (if any) in the bean definition.
207+
* Note that the provided arguments need to match a specific candidate constructor /
208+
* factory method in the order of declared parameters.
205209
* <p>This method goes into {@link ListableBeanFactory} by-type lookup territory
206210
* but may also be translated into a conventional by-name lookup based on the name
207211
* of the given type. For more extensive retrieval operations across sets of beans,

spring-beans/src/main/java/org/springframework/beans/factory/support/ConstructorResolver.java

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -121,11 +121,7 @@ public ConstructorResolver(AbstractAutowireCapableBeanFactory beanFactory) {
121121

122122
/**
123123
* "autowire constructor" (with constructor arguments by type) behavior.
124-
* Also applied if explicit constructor argument values are specified,
125-
* matching all remaining arguments with beans from the bean factory.
126-
* <p>This corresponds to constructor injection: In this mode, a Spring
127-
* bean factory is able to host components that expect constructor-based
128-
* dependency resolution.
124+
* Also applied if explicit constructor argument values are specified.
129125
* @param beanName the name of the bean
130126
* @param mbd the merged bean definition for the bean
131127
* @param chosenCtors chosen candidate constructors (or {@code null} if none)

0 commit comments

Comments
 (0)