<bean id="a" class="com.yundaex.wms.config.TestBeanChild" /> <bean id="b" class="com.yundaex.wms.config.TestBeanChild" factory-bean="a" factory-method="createDefault" />
public class TestBeanChild { int b = 1; public TestBeanDefault createDefault() { return new TestBeanDefault(); } }
public class TestBeanDefault { int b=2; }
静态工厂方法
public class TestBeanChild { int b = 1; public static TestBeanDefault createDefault() { return new TestBeanDefault(); } }
<bean id="a" class="com.yundaex.wms.config.TestBeanChild" /> <bean id="b" class="com.yundaex.wms.config.TestBeanChild" factory-method="createDefault" />
时间: 2024-11-08 22:41:40