Bean作用域singleton与prototype singleton 在spring IoC容器中仅存在一个Bean实例,Bean以单例方式存在prototype每次从容器中调用Bean时,都返回一个新的实例,即每次调用getBean()时,相当于执行new XxxBean()applicationContext. xml文件中默认为singleton选用的时候,线程不安全选择prototype,安全则选择singleton applicationContext.xml文件 当scope为prototype时 测试 当scope为prototype时 测试