Spring IOC 注入类型
注入类型
a)?????setter(重要)
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
???????xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
???????xsi:schemaLocation="http://www.springframework.org/schema/beans
???????????http://www.springframework.org/schema/beans/spring-beans-2.5.xsd">
??<bean id="u" ref="u" />
????
??</bean>
?
</beans>
b)?????构造方法
?<bean id="userService" ref="u" />
????-->
????<constructor-arg>
?????<ref bean="u"/>
????</constructor-arg>
</bean>
c)?????接口注入