Spring overloaded constructor injection
Posted
by
noob
on Stack Overflow
See other posts from Stack Overflow
or by noob
Published on 2012-12-13T17:02:03Z
Indexed on
2012/12/13
17:03 UTC
Read the original article
Hit count: 282
This is the code :
public class Triangle {
private String color;
private int height;
public Triangle(String color,int height){
this.color = color;
this.height = height;
}
public Triangle(int height ,String color){
this.color = color;
this.height = height;
}
public void draw() {
System.out.println("Triangle is drawn , +
"color:"+color+" ,height:"+height);
}
}
The Spring config-file is :
<bean id="triangle" class="org.tester.Triangle">
<constructor-arg value="20" />
<constructor-arg value="10" />
</bean>
Is there any specific rule to determine which constructor will be called by Spring ?
© Stack Overflow or respective owner