From e8b9c6d5ff6d48760d0abdd54147d9ed6c430a30 Mon Sep 17 00:00:00 2001 From: Oliver Gierke Date: Wed, 15 Sep 2010 06:37:05 +0000 Subject: [PATCH] SPR-7443 - Constructor arg resolution by name (doc) Added documentation on constructor argument disambiguation by using the argument names. --- .../src/beans-dependencies.xml | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/spring-framework-reference/src/beans-dependencies.xml b/spring-framework-reference/src/beans-dependencies.xml index 2f56f948b0b..f3cd4ba5970 100644 --- a/spring-framework-reference/src/beans-dependencies.xml +++ b/spring-framework-reference/src/beans-dependencies.xml @@ -158,6 +158,22 @@ public class ExampleBean { has two arguments of the same type. Note that the index is 0 based. + +
+ Constructor argument name + + As of Spring 3.0 you can also use the constructor parameter + name for value disambiguation: + + <bean id="exampleBean" class="examples.ExampleBean"> +<constructor-arg name="years" value="7500000"/> +<constructor-arg name="ultimateanswer" value="42"/> +</bean> + + Keep in mind that your code has to be compiled with the debug + flag enabled so that Spring can lookup the parameter name from the + constructor. +