1.简单方式
<bean id="userBean" class="com.boomsecret.bean.UserBean"/>
2.静态工厂
public class BeanFactory {
public static UserBean getUserBean() {
return new UserBean();
}
}
<bean id="userBean"
class="com.boomsecret.bean.BeanFactory"
factory-method="getUserBean"/>
3.实例工厂
<bean id="beanFactory" class="com.boomsecret.bean.BeanFactory"/>
<bean id="userBean" factory-bean="beanFactory" factory-method="getUserBean"/>
网友评论