1.使用类构造器实例化
- <bean id="personService" class="com.go123.service.impl.PersonServiceBean"/>
2.使用静态工厂方法实例化
- <bean id="personService" class="com.go123.service.impl.PersonFacory"
- factory-method="createPerson"/>
静态工厂类
- public class PersonFactory{
- public static PersonServiceBean createPerson(){
- return new PersonServiceBean();
- }
- }
3.使用实例工厂方法实例化:
- <bean id="personServiceFactory"
- class="com.go123.service.impl.PersonFactory"/>
- <bean id ="personService" factory-bean="personServiceFactory"
- factory-method="createPerson">
实例工厂类:
- public class PersonFactory{
- public PersonServiceBean createPerson(){
- return new PersonServiceBean();
- }
- }