【发布时间】:2016-01-03 05:30:37
【问题描述】:
如果我们在同一个 xml 中为同一个类创建一个具有不同 id 的新 bean,spring 会产生另一个单例 bean(在同一个 ApplicationContext 中)吗? 根据我的理解,单个 ApplicationContext 中应该只有一个 bean 实例。
下面的例子-
<bean id="bean1" class="com.myCompany.myPackage.MyClass" scope="singleton" />
<bean id="bean2" class="com.myCompany.myPackage.MyClass" scope="singleton" />
【问题讨论】:
-
这个link 可能对你有帮助。
标签: spring