@@ -234,6 +234,10 @@ For details about the mechanism for supplying arguments to the constructor (if r
234234and setting object instance properties after the object is constructed, see
235235xref:core/beans/dependencies/factory-collaborators.adoc[Injecting Dependencies].
236236
237+ NOTE: In the case of constructor arguments, the container can select a corresponding
238+ constructor among several overloaded constructors. That said, to avoid ambiguities,
239+ it is recommended to keep your constructor signatures as straightforward as possible.
240+
237241
238242[[beans-factory-class-static-factory-method]]
239243=== Instantiation with a Static Factory Method
@@ -294,6 +298,24 @@ For details about the mechanism for supplying (optional) arguments to the factor
294298and setting object instance properties after the object is returned from the factory,
295299see xref:core/beans/dependencies/factory-properties-detailed.adoc[Dependencies and Configuration in Detail].
296300
301+ NOTE: In the case of factory method arguments, the container can select a corresponding
302+ method among several overloaded methods of the same name. That said, to avoid ambiguities,
303+ it is recommended to keep your factory method signatures as straightforward as possible.
304+
305+ [TIP]
306+ ====
307+ A typical problematic case with factory method overloading is Mockito with its many
308+ overloads of the `mock` method. Choose the most specific variant of `mock` possible:
309+
310+ [source,xml,indent=0,subs="verbatim,quotes"]
311+ ----
312+ <bean id="clientService" class="org.mockito.Mockito" factory-method="mock">
313+ <constructor-arg type="java.lang.Class" value="examples.ClientService"/>
314+ <constructor-arg type="java.lang.String" value="clientService"/>
315+ </bean>
316+ ----
317+ ====
318+
297319
298320[[beans-factory-class-instance-factory-method]]
299321=== Instantiation by Using an Instance Factory Method
@@ -416,8 +438,8 @@ Kotlin::
416438======
417439
418440This approach shows that the factory bean itself can be managed and configured through
419- dependency injection (DI). See xref:core/beans/dependencies/factory-properties-detailed.adoc[Dependencies and Configuration in Detail]
420- .
441+ dependency injection (DI).
442+ See xref:core/beans/dependencies/factory-properties-detailed.adoc[Dependencies and Configuration in Detail] .
421443
422444NOTE: In Spring documentation, "factory bean" refers to a bean that is configured in the
423445Spring container and that creates objects through an
@@ -444,5 +466,3 @@ cases into account and returns the type of object that a `BeanFactory.getBean` c
444466going to return for the same bean name.
445467
446468
447-
448-
0 commit comments