1.Spring IOC Introduction:-
Spring IOC or Spring Inversion of Controller is the core of Spring Framework just like a brain in human body or a CPU in Computer.
The container will create the objects, wire them together, configure them, and manage their complete life cycle from creation till destruction.
Spring provides following two distinct types of containers
1. BeanFactory container - The BeanFactory enables you to read bean definitions and access them using the bean factory.
2. ApplicationContext container - The ApplicationContext container includes all functionality of the BeanFactory container. ApplicationContext container adds more enterprise-specific functionality such as the ability to resolve textual messages from a properties file and the ability to publish application events to interested event listeners.
Note: - Spring framework by default uses the concept of singleton design pattern
2.Inversion of Control principle
• Spring IOC manages java objects from instantiation to destruction through its BeanFactory.
• In nutshell Spring IOC is responsible for instantiating, initializing, and wiring beans.
• The container also manages the life cycle of beans.
• By Dependency Injection, the responsibility of creating objects is shifted from our application code to the Spring container and this phenomenon is called Inversion of Controller (IOC).
• Dependency injection in Spring framework helps in creating the required object without the use of new Keyword.
• The object can be created by various ways using @scope annotation on Spring Bean which can be available by default or on demand as well.
• Simplest way of dependency injection in spring is achieved with the help of @Component annotation, ConfigurableApplicationContext class and getBean() method.
• The responsibility of creating objects is shifted from our application code to the Spring container and this phenomenon is called IOC.
• Dependency Injection can be done by setter injection or constructor injection.
4.Ways to perform Dependency Injection in Spring framework