package com.hgh.spring.scope;
import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;
public class TestSpring {
public static void main(String[] args) {
ApplicationContext ac = new ClassPathXmlApplicationContext("bean-scope.xml");
//从容器中获取Bean
Person person = (Person) ac.getBean("person");
Person person2 = (Person) ac.getBean("person");
System.out.println(person2==person);//true
Person person3 = (Person) ac.getBean("person4");
Person person4 = (Person) ac.getBean("person4");
System.out.println(person3==person4);//false
}
}