1.使用类构造器实例化
<beanid=“orderService" class="cn.itcast.OrderServiceBean"/>
2.使用静态工厂方法实例化
<beanid="personService" class="cn.itcast.service.OrderFactory"factory-method="createOrder"/>
publicclass OrderFactory {
public static OrderServiceBean createOrder(){
return new OrderServiceBean();
}
}
3.使用实例工厂方法实例化:
<beanid="personServiceFactory"class="cn.itcast.service.OrderFactory"/>
<beanid="personService" factory-bean="personServiceFactory"factory-method="createOrder"/>
publicclass OrderFactory {
public OrderServiceBean createOrder(){
return new OrderServiceBean();
}
}