<?xml version="1.0" encoding="UTF-8"?> <beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:p="http://www.springframework.org/schema/p" xmlns:c="http://www.springframework.org/schema/c" xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd"> <- P! (Properties: properties) namespace, attribute set method is still to be set -> <bean id="user1" class="com.kuang.pojo.User" p:name="狂神" p:age="18" scope="singleton"/> <- C (constructor: Constructor)! Namespace attribute set method to set the still -> <bean id="user2" class="com.kuang.pojo.User" c:name="狂神" c:age="18" scope="prototype"/> <bean id="student" class="com.kuang.pojo.Student"> <property name="name" value="小明"/> </bean> <bean id="addr" class="com.kuang.pojo.Address"> <property name="address" value="重庆"/> </bean> <bean id="student1" class="com.kuang.pojo.Student"> <property name="name" value="小明"/> <property name="address" ref="addr"/> </bean> <bean id="student2" class="com.kuang.pojo.Student"> <property name="name" value="小明"/> <property name="address" ref="addr"/> <property name="books"> <array> <Value> Journey </ value> <Value> Dream of the Red </ value> <Value> Water Margin </ value> </array> </property> <property name="hobbys"> <list> <value>听歌</value> <Value> cinema </ value> <value>爬山</value> </list> </property> <property name="card"> <map> <Entry key = "China Post" value = "456456456465456" /> <entry key="建设" value="1456682255511"/> </map> </property> <property name="games"> <set> <value>LOL</value> <value>BOB</value> <value>COC</value> </set> </property> <property name="wife"><null/></property> <property name="info"> <props> <prop key="学号">20190604</prop> <Prop key = "Sex"> M </ prop> <Prop key = "Name"> Bob </ prop> </props> </property> </bean> </beans>
applicationContext.xml profile setter injection
Guess you like
Origin www.cnblogs.com/yslf/p/11955656.html
Recommended
Ranking