1.使用类 构造器实例化
<bean id="" class=""></bean>
2.使用静态工厂方法实例化
<bean id="personService2" class="com.cn.service.impl.PersonServiceBeanFactory" factory-method="createPersonServiceBean"></bean>
public class PersonServiceBeanFactory {
public static PersonServiceBean createPersonServiceBean(){
return new PersonServiceBean();
}
}
3.实例工厂方法
public PersonServiceBean createPersonServiceBean2(){
return new PersonServiceBean();
}
<bean id="PersonServiceBeanFactory" class="com.cn.service.impl.PersonServiceBeanFactory"></bean>
<bean id="personService3" factory-bean="PersonServiceBeanFactory" factory-method="createPersonServiceBean2"></bean>