弹簧参考手册说:
Spring 单例的范围最好描述为“每个容器和每个 bean”。
考虑这个代码片段:
ApplicationContext context = new ClassPathXmlApplicationContext("Beans.xml")
MyBean myobj=(MyBean)context.getBean("myBean"); //myBean is of singleton scope.
MyBean myobj1=(MyBean)context.getBean("myBean");
per container意味着如果我们执行context.getBean("myBean");两次,它将返回相同的 bean,即myobj==myobj1is true。
但是per beanin per container and per beanfrom 上面的语句是什么意思?