Rhyme/Spring 1.2. Container overview

11 篇文章 0 订阅

1.2. Container overview

The interface org.springframework.context.ApplicationContextrepresents the Spring IoC container and is responsible for instantiating, configuring, and assembling the aforementioned beans. The container gets its instructions on what objects to instantiate, configure, and assemble by reading configuration metadata. The configuration metadata is represented in XML, Java annotations, or Java code. It allows you to express the objects that compose your application and the rich interdependencies between such objects.

org.springframework.context.ApplicationContext

代表了spring IOC容器并且通过配置元数据来对bean进行实例化、装配等。这些配置元数据可以来自XML配置文件、java注解、或者直接用java代码定义。

Several implementations of the ApplicationContext interface are supplied out-of-the-box with Spring. In standalone applications it is common to create an instance of ClassPathXmlApplicationContext or FileSystemXmlApplicationContext. While XML has been the traditional format for defining configuration metadata you can instruct the container to use Java annotations or code as the metadata format by providing a small amount of XML configuration to declaratively enable support for these additional metadata formats.

spring 提供了多种针对ApplicationContext接口的实现,这些实现类可以在spring框架之外创建对象。在一个单独的应用程序中,可以使用ClassPathXmlApplicationContextFileSystemXmlApplicationContext实现类并根据xml配置文件或java注解或java 代码提供的配置元数据来创建一个对象。

In most application scenarios, explicit user code is not required to instantiate one or more instances of a Spring IoC container. For example, in a web application scenario, a simple eight (or so) lines of boilerplate web descriptor XML in the web.xml file of the application will typically suffice (see Convenient ApplicationContext instantiation for web applications). If you are using the Spring Tool Suite Eclipse-powered development environment this boilerplate configuration can be easily created with few mouse clicks or keystrokes.

通常情况下,我们是不需要用代码来手动的创建spring IOC容器,例如我们在开发web项目时,只需要在web.xml中对spring进行简单的配置即可

The following diagram is a high-level view of how Spring works. Your application classes are combined with configuration metadata so that after the ApplicationContext is created and initialized, you have a fully configured and executable system or application.

下图是spring如何工作的概览,简单来说,你应用中的类对象结合相关的配置元数据,在spring IOC 容器即ApplicationContext对象被创建并被实例化之后并可以拥有一个可执行的系统或应用。

这里写图片描述
Figure 1. The Spring IoC container

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值