Spring IOC Container

Spring Container

The Spring container (also known as IOC container) is at the core of the Spring framework.

In Spring, objects get stored and live in container. So it becomes significant to learn about the container as it will help us to manage the objects during its life-cycle.


The Spring Container is responsible to:

  • create the objects (bean)
  • wire the created objects together
  • configure the objects
  • manage the objects complete life cycle from creation till destruction.

Spring container uses Dependency Injection to manage all the components that forms an application.

Working of Spring container

The following diagram clearly explains the working of the Spring container from high level perspective.


Spring container by tutorialsinhand


Spring Container takes as input two things:

  1. Java based POJO classes
  2. Configuration Metadata which contains the complete information about What bean to create, its type, dependencies, etc.

The configuration metadata can be provided in three formats:

  1. XML config file
  2. Java config file
  3. Annotation based 

We can use any of the above format or all at the same time to provide the configuration metadata to Spring container. There is no restriction on which one to use. 

Using any of the above will help you in acheive your task.

As we have already explained that in Spring objects do not have responsibility of finding or creating their dependency that need to complete their task. Rather the Spring container takes the responsibility of giving the reference to the objects with whom they need to collaborate with.


Spring container is able to perform the tasks of creating the object, configuring them, wiring them together by reading the details given in configuration metadata.

Types of Spring container

Spring containers are generally categorized as:

  1. Bean Factories
  2. Application Contexts

We will learn more about both of them in next chapters of this tutorial.

Please Share this page
Views : 195
Like every other website we use cookies. By using our site you acknowledge that you have read and understand our Cookie Policy, Privacy Policy, and our Terms of Service. Learn more Got it!