Controlling Bean Creation Order with @DependsOn Annotation 1. Overview Spring, by default, manages beans’ lifecycle and arranges their initialization order. But, we can still customize it based on our needs. We can choose either the SmartLifeCycle interface or the @DependsOn annotation for managing initialization order. This tutorial explores the @DependsOn annotation… Continue Reading spring-depends-on

The Spring @Controller and @RestController Annotations 1. Overview In this quick tutorial, we’ll discuss the difference between @Controller and @RestController annotations in Spring MVC. The first annotation is used for traditional Spring controllers and has been part of the framework for a very long time. The @RestController annotation was introduced… Continue Reading spring-controller-vs-restcontroller

The Spring @Qualifier Annotation 1. Overview In this article, we’ll explore what the @Qualifier annotation can help us with, which problems it solves, and how to use it. We’ll also explain how it’s different from the @Primary annotation and from autowiring by name. 2. Autowire Need for Disambiguation The @Autowired… Continue Reading spring-qualifier-annotation

Spring Web Annotations 1. Overview In this tutorial, we’ll explore Spring Web annotations from the org.springframework.web.bind.annotation package. 2. @RequestMapping Simply put, @RequestMapping marks request handler methods inside @Controller classes; it can be configured using: path, or its aliases, name, and value: which URL the method is mapped to method: compatible… Continue Reading spring-mvc-annotations

Spring @RequestParam Annotation 1. Overview In this quick tutorial, we’ll explore Spring’s @RequestParam annotation. Simply put, we can use @RequestParam to extract query parameters, form parameters and even files from the request. We’ll discuss how to use @RequestParam and its attributes. We’ll also discuss the differences between @RequestParam and @PathVariable.… Continue Reading spring-request-param

Implementing a Custom Spring AOP Annotation 1. Introduction In this article, we’ll implement a custom AOP annotation using the AOP support in Spring. First, we’ll give a high-level overview of AOP, explaining what it is and its advantages. Following this, we’ll implement our annotation step by step, gradually building up… Continue Reading spring-aop-annotation

Spring @RequestMapping New Shortcut Annotations 1. Overview Spring 4.3. introduced some very cool method-level composed annotations to smooth out the handling @RequestMapping in typical Spring MVC projects. In this article, we will learn how to use them in an efficient way. 2. New Annotations Typically, if we want to implement… Continue Reading spring-new-requestmapping-shortcuts

A Spring Custom Annotation for a Better DAO Spring Persistence Spring Annotations 1. Overview In this tutorial, we’ll implement a custom Spring annotation with a bean post-processor. So how does this help? Simply put – we can reuse the same bean instead of having to create multiple, similar beans of… Continue Reading spring-annotation-bean-pre-processor

Guide to @SpringBootConfiguration in Spring Boot 1. Overview In this tutorial, we’ll briefly discuss the @SpringBootConfiguration annotation. We’ll also look at its usage in a Spring Boot application. [[spring boot application configuration]] === 2. Spring Boot Application Configuration [[spring boot application configuration]]@SpringBootConfiguration is a class-level annotation that is part of… Continue Reading springbootconfiguration-annotation