<?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"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
<!-- bean的实例化-->
<!-- 1.无参构造方法实例化-->
<!-- <bean id="userDao" class="com.ljx.dao.impl.UserDaoImpl" init-method="init" destroy-method="destroy"></bean>-->
<!-- 2.工厂静态方法实例化-->
<!-- <bean id="userDao" class="com.ljx.factory.StaticFactory" factory-method="getUserDao"></bean>-->
<!-- 3.工厂实例方法实例化-->
<!-- <bean id="factory" class="com.ljx.factory.DynamicFactory"></bean>-->
<!-- <bean id="userDao" factory-bean="factory" factory-method="getUserDao"></bean>-->
<!-- 属性、集合注入-->
<bean id="userDao" class="com.ljx.dao.impl.UserDaoImpl">
<property name="username" value="lixiang"/>
<property name="age" value="20"/>
<property name="strList">
<list>
<value>aaa</value>
<value>bbb</value>
<value>ccc</value>
</list>
</property>
<property name="userMap">
<map>
<entry key="u1" value-ref="user1"></entry>
<entry key="u2" value-ref="user2"></entry>
</map>
</property>
<property name="properties">
<props>
<prop key="p1">ppp1</prop>
<prop key="p2">ppp2</prop>
<prop key="p3">ppp3</prop>
</props>
</property>
</bean>
<bean id="user1" class="com.ljx.domain.User">
<property name="name" value="tom"/>
<property name="adder" value="北京"/>
</bean>
<bean id="user2" class="com.ljx.domain.User">
<property name="name" value="小明"/>
<property name="adder" value="天津"/>
</bean>
<!-- set方法注入-->
<!-- <bean id="userService" class="com.ljx.service.impl.UserServiceImpl">-->
<!-- <property name="userDao" ref="userDao"></property>-->
<!-- </bean>-->
<!-- p标签注入-->
<!-- <bean id="userService" class="com.ljx.service.impl.UserServiceImpl" p:userDao-ref="userDao"></bean>-->
<!-- 有参方法构造-->
<bean id="userService" class="com.ljx.service.impl.UserServiceImpl">
<constructor-arg name="userDao" ref="userDao"></constructor-arg>
</bean>
<!-- import导入其他spring分文件-->
<import resource="applicationContext-user.xml"/>
</beans>