java - 如果父对象不是单例,那么子对象也是单例吗?

标签 java spring singleton

我有一个不是单例的 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)。

引用文档中是这么说的: http://static.springsource.org/spring/docs/3.1.x/spring-framework-reference/html/beans.html#beans-child-bean-definitions

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/

相关文章:

java - 导入 org.apache.oro 无法解析

java - "while running the android game app"在 logcat 中给出警告信息

spring - 从 Grails 中的 Quartz 作业渲染 GSP

ios - 一个对象的变化应该影响同一类的其他对象

ios - 访问单例方法(ARC)时的iOS内存管理

java - JPA 中日期到日期时间的转换

java - 如何将 "nested for each"转换为 Java 8 Lambda/Stream 构造?

spring - 在哪里处理Spring DataAccessException

java - 如何在 Spring 中加载系统属性文件?

C++,再次调用单例类的析构函数