<bean id="foo1" class="com.wl.test.Foo">
<constructor-arg index="1">
<value>张军</value>
</constructor-arg>
<constructor-arg index="0">
<value>23</value>
</constructor-arg>
</bean>
在Foo类里,
public Foo(int id, String name) {
this.id = id;
this.name = name;
}
如果不给出默认构造方法的话,就会报错:Instantiation of bean failed; nested exception is org.springframework.beans.BeanInstantiationException: Could not instantiate bean class [com.wl.test.Foo]: No default constructor found;