3.实例工厂
<bean id = "bean3Factory " class = "BeanFactory"/>
<bean id = "bean3" factory-bean="bean3Factory " factory-method="getUser"/>
类方法是
public class BeanFactory{
public User getUser()
{
return new User() ;
}
}
2.静态实例工厂
<bean id = "bean2" class = "" factory-method="getUser" />
类方法是
public class BeanFactory{
public static User getUser()
{
return new User() ;
}
}
1.无参构造方法实例化
<bean id = "user" class ="" />
java类必须有无参构造方法