Spring Framework

Home/Spring Framework

Managed beans using @Component, @Repository, @Service

Introduction: In this tutorial, you will learn the different Spring stereotype annotations (@Component, @Repository and @Service) to declare any class as a Spring-managed Bean. Spring MVC also has several other annotations like @Controller and @RestController. The classes that are managed as beans in Spring are known as Managed Components. There are basically few stereotype annotations in spring that declare classes [Read More]

By |2020-08-17T06:16:12+00:00April 3rd, 2020|Categories: Spring Framework|Tags: |

RabbitMQ with Spring AMQP and Spring Boot

In this tutorial, we will explore the use of Spring AMQP to communicate with the RabbitMQ messaging middleware. All the previous article code examples are based on the RabbitMQ-Java-Client library. Spring AMQP also makes use of the same library, however, it provides a practical oriented approach to communicate with RabbitMQ. If you are already familiar with Spring stack, then you [Read More]

By |2021-04-08T05:54:34+00:00March 31st, 2020|Categories: RabbitMQ, 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 [Read More]

By |2020-04-24T18:26:47+00:00February 26th, 2020|Categories: Spring Framework|Tags: |

Dependency Injection: @Autowired, @Resource and @Inject

In Spring Framework, you can basically use any of the three annotations for Dependency Injection, namely @Autowired, @Resource and @Inject. The @Autowired annotation belongs to the core-spring, however, the other two belongs to the Java extension package @javax.annotation.Resource and @javax.inject.Inject. We will look into the use of each of these annotations with a practical use case, to help you choose [Read More]

By |2020-04-24T18:26:36+00:00February 23rd, 2020|Categories: Spring Framework|Tags: |

Spring BeanPostProcessor to customize beans

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 [Read More]

By |2020-04-24T18:26:19+00:00February 15th, 2020|Categories: Spring Framework|Tags: , |

Spring bean definition Inheritance

In Spring Framework, bean definition inheritance (bean configuration inheritance) is a valuable time-saving feature we must learn. As you know, a bean definition is nothing but the configuration for the Spring IoC container to create our bean as per the details. Refer to the article Inversion of Control and Dependency Injection in Spring, if you need to understand the basics [Read More]

By |2020-04-24T18:26:06+00:00February 13th, 2020|Categories: Spring Framework|Tags: |

Mapping and Injecting Collections in Spring

Spring Framework supports the injection of the Java Collection types List, Set, Map and Properties. You can use XML as well as annotations based configurations. We will learn Constructor, Setter, and Field injections for the collections using annotations based configurations in this article. The complete code example is available in the GitHub code repository. I recommend understanding the basics of [Read More]

By |2020-04-24T18:25:57+00:00January 22nd, 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 [Read More]

By |2020-04-24T18:25:40+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 [Read More]

By |2020-04-24T18:25:29+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 [Read More]

By |2020-04-24T18:25:18+00:00January 13th, 2020|Categories: Spring Framework|Tags: , |
Go to Top