Spring 支持3中依赖注入的方式
1、属性注入 通过setter 方法注入Bean的属性或依赖的对象。
<bean id = " " class = " ">
<property name = " " value = " "> </property>
<property name = " " value = " "> </property>
</bean>
2、构造器注入 通过构造方法注入Bean的属性值或依赖的对象,它保证Bean实例在实例化后就
可以使用
2.1 按索引匹配入参
<bean id = " " class = " ">
<constructor-arg value = " " index = "0"></constructor-arg>
<constructor-arg value = " " index = "1"></constructor-arg>
</bean>
2.2 按类型匹配入参
<bean id = " " class = " ">
<constructor-arg value = "value " type = "java.lang.String"></constructor-arg>
<constructor-arg value = " 5000" type = "double"></constructor-arg>
</bean>
3、工厂方法注入
原文:http://www.cnblogs.com/zoghin/p/4830856.html