我有一个不是单例的 Dao,从他扩展的其他对象,是否是单例?代码示例
<bean id="dao" class="parentDao"
scope="prototype">
</bean>
<bean id="childrenDao"
class="some.dao.extends.parentDao"
parent="parentDao">
</bean>
childrenDao 是单例吗?
最佳答案
更新:通过测试验证,作用域也是从父bean继承的,并且可以被子bean覆盖。所以在这种情况下,childrendDao 将是一个原型(prototype)。
A child bean definition inherits constructor argument values, property values, and method overrides from the parent, with the option to add new values. Any initialization method, destroy method, and/or static factory method settings that you specify will override the corresponding parent settings.
The remaining settings are always taken from the child definition: depends on, autowire mode, dependency check, singleton, scope, lazy init.
关于java - 如果父对象不是单例,那么子对象也是单例吗?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11532371/