Going records easy to remember
1, by way of injection setter <property>
The premise has provided setter methods
1.1 <! - injection method using the data of the normal data setter ->
<bean id="userService" class="com.test.SpringDI.userServiceImpl">
<! - The first ->
<property name="number" value="1232333"></property>
<! - second ->
<property name="number" >
<value>wechat</value>
</property>
</bean>
1.2 <! - injection method using the data reference data setter ->
<bean id="userService" class="com.test.SpringDI.userServiceImpl">
<! - The first ->
<property name="xxxDao" ref="xxxDao"></property>
<! - second ->
<property name="xxxDao" >
<ref bean="xxxDao">
</property>
</bean>
2, the injection parameters constructor
The premise of providing a default constructor to use the first constructor
<the bean ID = "that userService" class = "com.test.SpringDI.userServiceImpl">
<-! used constructor injection data by name ->
<-! <constructor Arg-name = "NUM" value = "123 "> </ Arg-constructor>
<constructor Arg-name =" S "value =" WeChat "> </ Arg-constructor> ->
<-! constructor injection by using the index data ->
<! - <constructor Arg-index = "0" value = "12,390,934"> </ Arg-constructor>
<constructor Arg-index = ". 1" value = "wechatmissing"> </ Arg-constructor> ->
</bean>
3, p namespace
<! - injected through the p-namespace data format setter is: p: attribute name = "" p: attribute name -ref = "" ->
<bean id="userService" class="com.test.SpringDI.userServiceImpl" p:number="9999" p:s="qqfeiche" p:userdao-ref="userDao">
</bean>
Watching basketball world championships, and so will eat barbecue, flattered.