Spring Bean Scopes

The Primary Spring bean scopes are Singleton and Prototype. In Singleton scope, the spring container instantiates only one instance of a bean per container. In Prototype scope, the container returns a new instance of a bean whenever we ask the container for that bean. Other bean scopes applicable only to web environments are request, session, … Read more

Spring Inner Bean Injection

A bean defined within the context of another bean is called a spring inner bean. It is similar to the concept of inner classes in java. e.g. In an ATM (Automated Teller Machine) system, it is possible for the Printer bean to be defined as an inner bean of ATM class. Github – Source Code … Read more

Spring Setter Injection

What is Setter Injection in Spring Setter Injection in Spring is a type of dependency injection in which the framework injects the dependent objects into the client using a setter method. The container first calls the no argument constructor and then calls the setters. The setter based injection can work even If some dependencies have … Read more

Spring Constructor Injection

Spring Constructor Injection is a form of Dependency Injection where the objects are injected into the client using the client constructor. Example of Spring Constructor injection Github – Source Code for this example In typical software development, classes collaborate with each other to achieve the desired functionality. e.g. In an ATM (Automated Teller Machine) system, … Read more

Dependency Injection in Spring, Introduction and types

Definition of Dependency Injection in Spring Dependency Injection is a software engineering pattern in which a dependent object is passed on to the client by an external agency such as the Spring container. Dependency Injection is one way to achieve Inversion of Control since the control of creating the Objects is not with the client … Read more