标签:
1、
<bean id="stage" class="com.test.pro.Stage">
2、测试类
package com.test.pro; import org.springframework.context.ApplicationContext; import org.springframework.context.support.ClassPathXmlApplicationContext; public class Main { public static void main(String[] args) { // TODO Auto-generated method stub ApplicationContext ctx=new ClassPathXmlApplicationContext("spring.xml"); Stage stage1=(Stage)ctx.getBean("stage"); Stage stage2=(Stage)ctx.getBean("stage"); System.out.println(stage1.equals(stage2));//判断两个实例是否相同 } }
3、当我们在xml中改变了bean的作用域之后
<bean id="stage" class="com.test.pro.Stage" scope="prototype">
标签:
原文地址:http://blog.csdn.net/itbuluoge/article/details/44498097