IoC container - Sudipta13samanta/Spring GitHub Wiki

  • What is Spring IoC container? -> The Spring IoC is responsible for creating the objects,managing them with dependency injection (DI), wiring them together, configuring them, as also managing their complete lifecycle.

  • What are the benefits of IOC? -> 1. IOC or dependency injection minimizes the amount of code in an application.

  1. It makes easy to test applications, since no singletons or JNDI lookup mechanisms are required in unit tests.
  2. Loose coupling is promoted with minimal effort and least intrusive mechanism.
  3. IOC containers support eager instantiation and lazy loading of services.
  • How many types of IOC containers are there in spring? ->
  • BeanFactory: A BeanFactory is essentially nothing more than the interface for an advanced factory capable of maintaining a registry of different beans and their dependencies. The BeanFactory enables you to read bean definitions and access them using the bean factory.
  • ApplicationContext: The ApplicationContext is the central interface within a Spring application for providing configuration information to the application. It is read-only at run time, but can be reloaded if necessary and supported by the application. A number of classes implement the ApplicationContext interface, allowing for a variety of configuration options and types of applications.