测试类:
public class Test1 {
ClassPathXmlApplicationContext xmlBeanFactory = null;
@Before
public void initXmlBeanFactory() {
System.out.println("n========测试方法开始=======n");
xmlBeanFactory = new ClassPathXmlApplicationContext("spring3.xml");
}
@After
public void after() {
System.out.println("n========测试方法结束=======n");
}
@Test
public void test8() {
System.out.println(xmlBeanFactory.getBean("colorFactoryBean"));
System.out.println("===================");
System.out.println(xmlBeanFactory.getBean("&colorFactoryBean"));
}
}
测试结果:
========测试方法开始======= 十二月 09, 2019 4:49:52 下午 org.springframework.context.support.ClassPathXmlApplicationContext prepareRefresh 信息: Refreshing org.springframework.context.support.ClassPathXmlApplicationContext@2e5c649: startup date [Mon Dec 09 16:49:52 CST 2019]; root of context hierarchy 十二月 09, 2019 4:49:52 下午 org.springframework.beans.factory.xml.XmlBeanDefinitionReader loadBeanDefinitions 信息: Loading XML bean definitions from class path resource [spring3.xml] ColorFactoryBean...getObject... Color [car=null] =================== spring2.ColorFactoryBean@6ddf90b0 ========测试方法结束=======
以上就是本文的全部内容,希望对大家的学习有所帮助,也希望大家多多支持易采站长站。










