Different Types of Spring Containers


There are two distinct types of spring containers as mentioned below:

1. BeanFactory Container:

  • This is the simplest container providing basic support for Dependency Injection and defined by the org.springframework.beans.factory.BeanFactory interface. Related interfaces, such as BeanFactoryAware, InitializingBean, DisposableBean, can provide callbacks which can be configured for the different phases of the Spring Bean’s life cycle.
  • BeanFactory, by default lazy loads the beans, it creates the bean only when the getBean() method is called.

2. ApplicationContext Container:

  • This container adds more enterprise-specific functionalities such as ability to resolve textual messages from a properties file and ability to publish application events to the interested event listeners. This container is defined by org.springframework.context.ApplicationContext interface.
  • ApplicationContext loads all Spring Beans upon start-up unlike BeanFactory.

ApplicationContext container includes all functionality of the BeanFactory container, so it is generally recommended over the BeanFactory. BeanFactory can be used for light weight applications like mobile devices or applet based applications where data volume and speed is significant.

 

One thought on “Different Types of Spring Containers

  1. uday December 3, 2018 / 11:45 am

    n0 sir there is only one ioc container
    but bay of creation ioc container are two
    beanfactory
    or
    applicationcontaext

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.