Category: Spring Core
-
Instantiation of bean by using an instance factory method in Spring
Spring allows instantiation of bean using instance factory method. Using instance factory allows to keep separate the logic to create the bean separate. In this article we’ll discuss the instantiation of bean by using instance factory method in Spring. Instantiation with an instance factory method invokes the non-static method of the existing bean in the…
-
Instantiation of bean with a Static Factory Method in Spring
Spring allows following three ways to instantiate beans: Instantiation with a constructor Instantiation with a static factory method Instantiation by using an instance factory method In this article we’ll discuss instantiation with a static factory method. When defining configuration for a bean which is created with a static factory method, we use two attributes class…
-
Overview of bean in Spring and naming beans
1. Introduction Beans in application are same as bricks in house. A bean is an object of your application. An application is made of several beans. A bean is an object which is instantiated, assembled (refers to injection of dependencies) and managed by Spring IoC container. IoC container instantiates, assembles and manages the beans using…
-
Spring IoC Container
One of the most important topic when we start learning Spring is Spring IoC container. We need to understand what a Spring IoC Container is, and how does it work, to understand how Spring works. We’ll understand this by answering few important questions about Spring IoC container. What is Spring IoC Container? Spring IoC container…
-
Setter Based Dependency Injection in Spring
In this article, we’ll discuss Setter-Based Dependency Injection within Spring. Setter-based dependency is accomplished by the container calling setter methods on beans after invoking a no-argument constructor or a no-argument static factory method to instantiate your bean. Let us now understand setter-based dependency injection with the help of an example. Suppose we have a car.…
-
Constructor Based Dependency Injection in Spring
1. Introduction to constructor-based dependency injection In this article, we’ll discuss Constructor-Based Dependency Injection within Spring. This type of dependency injection means – the required dependencies are passed into a class at the time of creation of object (or instantiation). The fields or member variables in a class are the dependencies which a class needs.…
-
Hello World in Spring using XML Configuration and Annotation
1. Getting started with Spring To start with Spring, we should have Spring JAR files. There are two ways to get Spring JAR files: Download the JAR files. The URL at the time of writing this tutorial is https://repo.spring.io/release/org/springframework/spring/. Checkout the latest code from GitHub repository and build JARs. Spring packaging of JARs is modular.…
-
Introduction to Spring Framework
Spring was developed by Rod Johnson. The first version of Spring was released in October 2002. Spring is a lightweight framework for creating Java applications. Spring can be used to create web as well as stand-alone Java application. In the above statement, when we say that Spring is lightweight, we don’t mean to say that…