<?xml version="1.0" encoding="gb2312"?>
<!-- default-lazy-init="true" 为beans下所有的进行延迟初始化 -->
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:aop="http://www.springframework.org/schema/aop"
xmlns:tx="http://www.springframework.org/schema/tx"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.0.xsd
http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-2.0.xsd
http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-2.0.xsd" >
<!-- id 不能是特殊字符,如:“/”,如果有特殊字符则应该用name。 交给Spring管理的Bean类-->
<!--默认情况下(没有配置scope属性)是单实例 指的是每次获取Bean都是同一个对象 初始化容器时候就实例化实例化 PersonService
可是使用lazy-init="true" 进行延迟初始化 ,即第一次获取bean的时候才初始化
scope="prototype"每次获取Bean都是新的对象 第一次请求(调用getBean)的时候实例化 PersonService .
init-method="" 初始化 方法。即当bean被初始化后接下来会继续执行的方法。
destroy-method=""
-->
<bean id="personService" class="com.milo.services.impl.PersonServiceBean"
lazy-init="false" init-method="init" destroy-method="destory"/>
<!-- 使用 类构造器方法 实例化 PersonService
<bean id="personService1" class="com.milo.services.impl.PersonServiceBean" scope="prototype"/>
使用 静态工厂方法 实例化PersonService
<bean id="personService2" class="com.milo.services.impl.PersonServiceBeanFactory" factory-method="createPersonServiceBean"/>
使用 实例化工厂方法 实例化PersonService
<bean id="personServiceFactory" class="com.milo.services.impl.PersonServiceBeanFactory"/>
<bean id="personService3" factory-bean="personServiceFactory" factory-method="createPersonServiceBean2"/>
-->
</beans>