
Baeldung » Spring
223 FOLLOWERS
Have a look through a list of in-depth tutorials on the various Spring modules, including Spring MVC, Spring Security, Spring Cloud and many more. Baeldung helps developers explore the Java ecosystem and simply be better engineers. We publish to-the-point guides and courses, with a strong focus on building web applications, Spring, Spring Security, and RESTful APIs.
Baeldung » Spring
1d ago
1. Overview
In this tutorial, we’ll learn how to modify an HTTP request before it reaches the controller in a Spring Boot application. Web applications and RESTful web services often employ this technique to address common concerns like transforming or enriching the incoming HTTP requests before they hit the actual controllers. This promotes loose coupling and considerably reduces development effort.
2. Modify Request With Filters
Often, applications have to perform generic operations such as authentication, logging, escaping HTML characters, etc. Filters are an excellent choice to take care o ..read more
Baeldung » Spring
5d ago
1. Overview
Sometimes, we require code execution to be asynchronous for better application performance and responsiveness. Also, we may want to automatically re-invoke the code on any exception, as we expect to encounter occasional failures like a network glitch.
In this tutorial, we’ll learn to implement an asynchronous execution with automatic retry in a Spring application.
We’ll explore Spring’s support for async and retry operations.
2. Example Application in Spring Boot
Let’s imagine we need to build a simple microservice that calls a downstream service to process some data.
2.1. Maven De ..read more
Baeldung » Spring
1w ago
1. Overview
In this tutorial, we’ll learn how to set beans in the Spring context to nulls. This might be useful in some cases, such as testing when we don’t want to provide mocks. Also, while using some optional features, we might want to avoid creating implementation and pass null instead.
Additionally, this way, we can create placeholders if we want to defer the decision of picking needed implementation outside of the beans’ lifecycle. Lastly, this technique might be the first step during the deprecation process, which involves removing specific beans from the context.
2. Components Setup
A ..read more
Baeldung » Spring
3w ago
1. Overview
Spring Reactive programming has introduced a new age of applications that are both responsive and scalable. Project Reactor is a superior toolkit for managing asynchronous and event-driven programming within this ecosystem.
MathFlux is a component of Project Reactor, which provides us with a variety of mathematical functions designed for reactive programming.
In this tutorial, we’ll explore the MathFlux module from Project Reactor and understand how to utilize it to execute various mathematical operations on reactive streams.
2. Maven Dependency
Let’s create a Spring Boot project i ..read more
Baeldung » Spring
3w ago
1. Introduction
In this quick tutorial, we’re going to look into a relatively new Spring Boot annotation called @ConditionalOnThreading.
We’ll discover what this annotation’s condition is and how to satisfy it in order to create the bean.
2. Conditional Annotations
Although we’ve already covered conditional annotations in Spring Boot, it’s worth very briefly recalling them again.
Conditional annotations provide a way to register a bean in BeanFactory only if various specific conditions are met. Developers define these conditions for each annotation individually by using the Condition interface ..read more
Baeldung » Spring
3w ago
1. Overview
Frequently, we find ourselves tasked with designing applications that must deliver localized messages within a multilingual environment. In such scenarios, delivering messages in the user’s selected language is a common practice.
When we receive client requests to a REST web service, we must ensure the incoming client requests meet the predefined validation rules before processing them. Validations aim to maintain data integrity and enhance system security. The service is responsible for providing informative messages to indicate what’s wrong with the request whenever the validatio ..read more
Baeldung » Spring
1M ago
1. Introduction
RestClient is a synchronous HTTP client introduced in Spring Framework 6.1 M2 that supersedes RestTemplate. A synchronous HTTP client sends and receives HTTP requests and responses in a blocking manner, meaning it waits for each request to complete before proceeding to the next one.
In this article, we’ll explore what RestClient offers and how it compares to RestTemplate.
2. RestClient and RestTemplate
RestTemplate, as the name suggests, is built on a template design pattern. It’s a behavioral design pattern that defines the skeleton of an algorithm in a method, allowing ..read more
Baeldung » Spring
1M ago
1. Overview
Security is a fundamental concern in modern web applications, particularly with the abundance of AI-powered apps heavily reliant on user data. Safeguarding this sensitive information and ensuring a secure user experience are non-negotiable priorities. Spring Security, designed to tackle these concerns, hinges on two critical components: HttpSecurity and WebSecurity.
In this tutorial, we’ll extensively explore and compare HttpSecurity and WebSecurity. Our aim will be to understand their unique roles and functionalities.
2. Spring Security
Spring Security, an extension of the Spring ..read more
Baeldung » Spring
1M ago
1. Overview
In this tutorial, we’ll learn about the ConnectionDetails interface introduced in Spring Boot 3.1 to externalize the connection properties. Spring Boot provides out-of-the-box abstractions to integrate with remote services like relational databases, NoSQL databases, messaging services, etc.
Traditionally, the application.properties file is used for storing the connection details of the remote services. Hence, it becomes difficult to externalize these properties to an external service like AWS Secret Manager, Hashicorp Vault, etc.
To address this concern, Spring Boot has intro ..read more
Baeldung » Spring
1M ago
1. Introduction
GraalVM compiles Java applications into machine executables using its Ahead-Of-Time (AOT) compiler. These executables execute directly into the target machine without using a Just-In-Time (JIT) compiler. The GraalVM-produced binaries are smaller, have a fast start-up time, and provide peak performance without any warm-up. Besides, these executables have a lower memory footprint and CPU than the applications running on JVM.
Docker lets us package software components into a Docker Image and run as a Docker container. A Docker container contains everything the application needs to ..read more