Spring中实例化Bean的3种方式
实例化Bean的3种方式:
1.使用类构造器实例化:
<bean id="personServiceBean" name="code"><bean id="peronServiceBeanFactory" name="code">package com.spring.service.impl;public class PersonServiceBeanFactory {public static PersonServiceBean pcreatePersonServiceBanFactory() {return new PersonServiceBean(); }}
??
?3.使用示例工厂方法实例化:
<bean id="personServiceBeanFactory" factory-bean="personServiceBeanFactory"factory-method="createPersonServiceBanFactory"></bean>
?PersonServiceBeanFactory代码如下:
package com.spring.service.impl;public class PersonServiceBeanFactory {public PersonServiceBean createPersonServiceBanFactory() {return new PersonServiceBean(); }}
?
1 楼 yuwensan126 2011-10-16 介绍这三种方法有什么目的,是让我们知道Spring容器如何做的实例化吗?