Spring Container Hierarchy

本文介绍了Spring框架中容器层级结构的概念及其工作原理。通过使用层级结构,可以实现多个上下文之间的资源共享,确保依赖关系与应用逻辑层保持一致。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

首先引用一段对Spring Container Hierarchy的理解

[quote]The Spring framework is used as a general application framework. The objects making up the application are being wired up by the Spring framework based on a number of XML configuration files, generally one per layer. The Spring ContextSingletonBeanFactoryLocator class is used to create multiple hierarchical Spring IoC container instances, also called bean factory or application context in Spring parlance, from these XML configuration files. For the container of each layer, the container of the lower layer is the parent container.

[img]http://www.mod4j.org/documentation/1.0.0/application-architecture/images/spring-config.jpg[/img]

Beans defined in a direct or indirect parent context are visible in the child context, but not vice versa. This hierarchical container is then used as the parent container of a web application container. In this way, containers and the beans contained in them, may be shared between several web applications, and loaded only once. Moreover, the hierarchical composition of the container guarantees that dependencies between them are parallel to the depencencies between the layers of the logical view. See section 3.9 Glue code and the evil singleton in [Spring25] and the Javadoc for ContextSingletonBeanFactoryLocator for more details.[/quote]

源自:[url]http://www.mod4j.org/documentation/1.0.0/application-architecture/mod4j-application-architecture.html[/url](Part 3.3)

Spring container hierarchy 的特点如下:
1. 该hierarchy是树形结构,即任意一个child container 都只能有一个parent container,不允许多重继承的存在;
2.
3.
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值