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

Spring Boot Annotations 1. Overview Spring Boot made configuring Spring easier with its auto-configuration feature. In this quick tutorial, we’ll explore the annotations from the org.springframework.boot.autoconfigure and org.springframework.boot.autoconfigure.condition packages. 2. @SpringBootApplication We use this annotation to mark the main class of a Spring Boot application: @SpringBootApplication class VehicleFactoryApplication { public… Continue Reading spring-boot-annotations

Spring Null-Safety Annotations 1. Overview Starting with Spring 5, we now have access to an interesting feature helping us write safer code. This feature is called null-safety, a group of annotations working like a safeguard that watches out for potential null references. Rather than letting us get away with unsafe… Continue Reading spring-null-safety-annotations

Guide to @ConfigurationProperties in Spring Boot 1. Introduction One handy feature of Spring Boot is externalized configuration and easy access to properties defined in properties files. An earlier article described various ways in which this can be done. We are now going to explore the @ConfigurationProperties annotation in greater detail.… Continue Reading configuration-properties-in-spring-boot

Spring Data MongoDB – Indexes, Annotations and Converters 1. Overview This tutorial will explore some of the core features of Spring Data MongoDB – indexing, common annotations and converters. 2. Indexes ==== 2.1. @Indexed This annotation marks the field as indexed in MongoDB: @QueryEntity @Document public class User { @Indexed… Continue Reading spring-data-mongodb-index-annotations-converter

Spring 5 Testing with @EnabledIf Annotation 1. Introduction In this quick article, we’ll discover the @EnabledIf and @DisabledIf annotations in Spring 5 using JUnit 5. Simply put, those annotations make it possible to disable/enable particular test if a specified condition is met. We’ll use a simple test class to show… Continue Reading spring-5-enabledIf

Spring Data Annotations 1. Introduction Spring Data provides an abstraction over data storage technologies. Therefore, our business logic code can be much more independent of the underlying persistence implementation. Also, Spring simplifies the handling of implementation-dependent details of data storage. In this tutorial, we’ll see the most common annotations of… Continue Reading spring-data-annotations

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 @ServletComponentScan Annotation in Spring Boot 1. Overview In this article, we’ll go through the new @ServletComponentScan annotation in Spring Boot. The aim is to support the following Servlet 3.0 annotations: javax.servlet.annotation.WebFilter javax.servlet.annotation.WebListener javax.servlet.annotation.WebServlet @WebServlet, @WebFilter, and @WebListener annotated classes can be automatically registered with an embedded Servlet container by… Continue Reading spring-servletcomponentscan