在spring基础(一)中,我们谈到了spring容器创建对象的三种方式,现在我们来谈一下
spring容器创建对象的时机:
那么,我们如何判断一个对象是在spring容器启动的时候创建的呢 还是在我们调用这个对象的时候创建的?
在单例的情况下:
在上面一个spring基础(一)中,我们写了如下的测试类:
public class testHelloSpring {
@Test
public void test1(){
//启动spring容器
ApplicationContext applicationContext=new ClassPathXmlApplicationContext("applicationContext.xml");
//得到helloSpring对象
helloSpring helloSpring=(helloSpring) applicationContext.getBean(