- scope="singleton" means singleton, the same bean can only get the same object
- Scope="prototype" means multiple cases, the same bean obtains different objects
public class People {
private String name;
}
public class Test {
public static void main(String[] args) {
ApplicationContext ac=new ClassPathXmlApplicationContext("applicationContext.xml");
People peo=ac.getBean("people",People.class);
People peo2=ac.getBean("people",People.class);
System.out.println(peo);
System.out.println(peo2);
}
}
Single case test
<bean id="people" class="cn.wit.test.People" scope="singleton"></bean>
Multiple test
<bean id="people" class="cn.wit.test.People" scope="prototype"></bean>