- 完善注入信息
<?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.xsd">
<bean id="address" class="com.kuang.pojo.Address">
<property name="address">
<value>西安</value>
</property>
</bean>
<bean id="student" class="com.kuang.pojo.Student">
<!-- 第一种:普通注入,value -->
<property name="name" value="秦疆"/>
<!-- 第二种: Bean注入,ref -->
<property name="address" ref="address"/>
<!-- 数组注入,ref-->
<property name="books">
<array>
<value>《红楼梦》</value>
<value>《水浒传》</value>
<value>《西游记》</value>
<value>《三国演义》</value>
</array>
</property>
<!-- list -->
<property name="hobbys">
<list>
<value>听歌</value>
<value>敲代码</value>
<value>看电影</value>
</list>
</property>
<!-- Map -->
<property name="card">
<map>
<entry key="身份证" value="1111111222223333"/>
<entry key="银行卡" value="12312313131313131"/>
</map>
</property>
<!-- set -->
<property name="games">
<set>
<value>LOL</value>
<value>COC</value>
<value>BOB</value>
</set>
</property>
<!-- null -->
<property name="wife">
<null/>
</property>
<!-- Properties -->
<property name="info">
<props>
<prop key="driver">mysql</prop>
<prop key="url">男</prop>
<prop key="username">root</prop>
<prop key="password">123456</prop>
</props>
</property>
</bean>
</beans>
原创文章,作者:ItWorker,如若转载,请注明出处:https://blog.ytso.com/280968.html