Spring Tutorial

Read property files in using @PropertySource in Spring

Introduction: The @PropertySource annotation in Spring provides a convenient and declarative mechanism for reading properties files. Properties files contain key-value pairs, e.g. app.log.level = DEBUG. In this article, you will learn to read a value from the property file using @PropertySource and access the specific values using @Value annotation and Environment field. If you are new to Spring, make sure [...]

By |2024-04-02T10:26:39+00:00April 6th, 2020|Categories: Spring Framework|Tags: , , |

Classpath Scanning using @ComponentScan and Filters

Introduction: A Classpath scanning basically means, detecting the classes that need to be managed by the Spring under a specified package. You need to make use of the spring @ComponentScan annotation with the @Configuration for classpath scanning. This annotation allows you to specify a base package and also a filter if needed to fine control the package scanning. We will [...]

By |2024-04-02T10:32:13+00:00April 4th, 2020|Categories: Spring Framework|Tags: |

Fine-tune auto wiring using @Primary and @Qualifier

Introduction Autowiring by type can lead to ambiguity when we have multiple beans of the same base class type. Because there are multiple beans of the same type, it is important to have control over the bean selection process. Spring provides @Primary annotation which declares a specific bean as primary, which means primary bean will be given higher preferences when [...]

By |2024-04-02T07:57:26+00:00February 26th, 2020|Categories: Spring Framework|Tags: |

Spring Beans Customization by Leveraging BeanPostProcessor

Spring BeanPostProcessor beans are a special kind of beans that get created before any other beans and Spring allows you to assign customize callbacks to it. Spring provides the BeanPostProcessor interface, you can implement its methods to provide your own instantiation logic and dependency resolution logic. NOTE - the following before working with BeanPostProcessor. BeanPostProcessor methods are executed after the [...]

By |2024-04-01T19:01:47+00:00February 15th, 2020|Categories: Spring Framework|Tags: , |

Spring bean Lifecycle Callbacks

In this article, you will learn the Spring bean lifecycle and different ways to run bean initialization callbacks and bean destruction callbacks. Bean lifecycle simply means you want to execute callbacks before the spring bean is available to use and similarly execute callbacks before the bean is destroyed. There are several ways to configure the Spring bean lifecycle callbacks as [...]

By |2024-04-02T11:20:54+00:00January 17th, 2020|Categories: Spring Framework|Tags: , , |

Inversion of Control and Dependency Injection in Spring

Inversion of Control (IoC) and Dependency Injection (DI) are programming patterns for decoupling the Class dependencies. In this article, we will talk about IoC and DI with respect to Spring Framework. Read High Level introduction of Spring Framework if you are new to Spring. 1. What is Inversion of Control (IoC)? For simplicity, let's say class Vehicle is dependent on [...]

By |2024-04-01T13:29:17+00:00January 16th, 2020|Categories: Spring Framework|Tags: , , , |

Spring Bean Scopes – @Scope annotation

In this article, you will learn about Spring Bean Scopes using @Scope annotation and XML configurations. If you are new to Spring, make sure you understand Dependency Injection in Spring. Creating a bean means, you create the actual instance of the class with the dependencies injected based on the bean definition. Bean definition is like a recipe, you can create [...]

By |2024-04-01T13:35:53+00:00January 13th, 2020|Categories: Spring Framework|Tags: , |

A high-level introduction to Spring Framework

What is the Spring Framework? The age-old answer to this question is, "Spring is a Dependency Injection Framework". In reality, it is much more than that. Spring is the most popular Java Enterprise application development framework, it comes with many tools and libraries to solve almost any problem in the java world. May it be microservices or a simple database-driven [...]

By |2024-04-01T13:32:39+00:00January 4th, 2020|Categories: Spring Framework|Tags: , |
Go to Top