美文网首页spring学习
IoC容器的解释

IoC容器的解释

作者: 低调_0c1d | 来源:发表于2018-07-29 16:27 被阅读1次

官网说明

原文地址

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 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.

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,可以通过鼠标点击完成这些令人无聊的配置。

相关文章

  • IoC容器的解释

    官网说明 原文地址 https://docs.spring.io/spring/docs/5.0.8.RELEAS...

  • Spring学习

    IOC (接口) 1、IOC思想基于IOC容器完成,IOC容器底层就是对象工厂; 2、Spring提供的IOC容器...

  • Spring(八)Bean装配 基于java容器

    解释 通过@Bean注解将创建的对象注入到ioc容器中 例子 测试

  • 2.IOC原理分析

    要想使用Spring IOC,必须要创建Spring IOC容器 ? 什么是IOC容器? 所谓的IoC容器就是指的...

  • 2018-06-08

    IOC 容器 IOC容器和beans Spring实现了IOC (Inversion of Control)(控制...

  • spring-core-1.1~1.9 IoC容器

    1. IoC容器 本章介绍Spring的控制反转,即IoC容器. 1.1 Spring IoC容器和bean简介 ...

  • 一、Spring核心篇

    第2章Spring Framework的核心:IoC容器的实现 2.1Spring IoC容器概述 1.IOC容器...

  • IoC(二)容器基本原理

    2.2.1 IoC容器的概念 IoC容器就是具有依赖注入功能的容器,IoC容器负责实例化、定位、配置应用程序中的...

  • Spring Ioc 容器原理

    IOC容器的概念 IOC容器就是具有依赖注入功能的容器,IOC容器负责实例化、定位、配置应用程序中的对象及建立这些...

  • Spring源码系列-IOC与DI 1.2

    IOC容器概念 ioc容器就是具有依赖注入功能的容器,ioc容器负责实例化,定位、配置应用程序中的对象及建立这些对...

网友评论

    本文标题:IoC容器的解释

    本文链接:https://www.haomeiwen.com/subject/muzzmftx.html