官网说明
原文地址
https://docs.spring.io/spring/docs/5.0.8.RELEASE/spring-framework-reference//core.html#beans
原文内容
The interface
org.springframework.context.ApplicationContext
represents 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.
Several implementations of the
ApplicationContext
interface are supplied out-of-the-box with Spring. In standalone applications it is common to create an instance ofClassPathXmlApplicationContext
orFileSystemXmlApplicationContext
. 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.
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.
个人解释
org.springframework.context.ApplicationContext代表Spring IoC容器,它负责实例化、配置和集成bean。Ioc容器通过读取配置元数据来获得它实例化、配置和集成bean的说明。配置元数据通过xml文件、java注解或者java代码来表示。它允许你表达应用中的对象以及对象之间丰富的依赖关系。
在Spring中与很多Application接口的实现。在独立的应用中通常需要创建一个ClassPathXmlApplicationContext或者FileSystemXmlApplicationContext的实现。因为Xml是比较传统哦定义配置元数据的方式,所以也可以创建很少的XML配置文件和Java注解或代码来完成配置元数据的说明。
在大多数应用场景,开发者的代码不需要实例化IoC容器的实例。例如在web应用中,web.xml文件中的8行代码就足够实例化一个IoC容器。如果使用Spring Tool Suite之类的IDE,可以通过鼠标点击完成这些令人无聊的配置。