Skip to content

Commit e8b9c6d

Browse files
committed
SPR-7443 - Constructor arg resolution by name (doc)
Added documentation on constructor argument disambiguation by using the argument names.
1 parent b2b195e commit e8b9c6d

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

spring-framework-reference/src/beans-dependencies.xml

+16
Original file line numberDiff line numberDiff line change
@@ -158,6 +158,22 @@ public class ExampleBean {
158158
has two arguments of the same type. Note that the <emphasis>index is
159159
0 based</emphasis>.</para>
160160
</section>
161+
162+
<section id="beans-factory-ctor-arguments-name">
163+
<title>Constructor argument name</title>
164+
165+
<para>As of Spring 3.0 you can also use the constructor parameter
166+
name for value disambiguation:</para>
167+
168+
<programlisting language="xml">&lt;bean id="exampleBean" class="examples.ExampleBean"&gt;
169+
&lt;constructor-arg name="years" value="7500000"/&gt;
170+
&lt;constructor-arg name="ultimateanswer" value="42"/&gt;
171+
&lt;/bean&gt;</programlisting>
172+
173+
<para>Keep in mind that your code has to be compiled with the debug
174+
flag enabled so that Spring can lookup the parameter name from the
175+
constructor.</para>
176+
</section>
161177
</section>
162178
</section>
163179

0 commit comments

Comments
 (0)