ref vs idref attributes in spring bean declaration
Here is a little more verbose example, suppose you have two beans A and B:
<bean class="A" id="a" /><bean class="B"/> <constructor-arg> <ref bean="a"/> <idref bean="a"/> </constructor-arg></bean>
In this case B would have a constructor that would look like this:
public B(A a, String string) { string.equals("a"); //true}
So with ref you can reference an object and with idref you just reference the name of the bean
ref
is used to pass the bean that the ref refers to.idref
is used to pass the name of the bean (as aString
) that is referred to.