Spring @ComponentScan – Filter Types 1. Overview In an earlier tutorial, we learned about the basics of Spring component scans. In this write-up, we’ll see the different types of filter options available with the @ComponentScan annotation. 2. @ComponentScan Filter By default, classes annotated with @Component, @Repository, @Service, @Controller are registered as… Continue Reading spring-componentscan-filter-type

Spring Core Annotations 1. Overview We can leverage the capabilities of Spring DI engine using the annotations in the org.springframework.beans.factory.annotation and org.springframework.context.annotation packages. We often call these “Spring core annotations” and we’ll review them in this tutorial. 2. DI-Related Annotations ==== 2.1. @Autowired We can use the @Autowired to mark a dependency… Continue Reading spring-core-annotations

XML-Based Injection in Spring 1. Introduction In this basic tutorial, we’ll learn how to do simple XML-based bean configuration with the Spring Framework. 2. Overview Let’s start by adding Spring’s library dependency in the pom.xml: <dependency> <groupId>org.springframework</groupId> <artifactId>spring-context</artifactId> <version>5.1.4.RELEASE</version> </dependency> The latest version of the Spring dependency can be found… Continue Reading spring-xml-injection

Spring Bean Annotations 1. Overview In this article, we’ll discuss the most common Spring bean annotations used to define different types of beans. There’re several ways to configure beans in a Spring container. We can declare them using XML configuration. We can declare beans using the @Bean annotation in a… Continue Reading spring-bean-annotations

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 @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