Baeldung » Spring
270 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
4d ago
1. Introduction
In the realm of database management, ensuring consistency and traceability of schema changes is a good practice for maintaining data integrity and application reliability. Liquibase, a widely adopted database schema change management tool, helps us version control and track database changes seamlessly across various environments.
However, as applications grow in complexity, it becomes imperative to organize database objects efficiently. While PostgreSQL defaults to the public schema, best practices advocate for segregating application-specific entities into dedicated schemas.
I ..read more
Baeldung » Spring
4d ago
1. Overview
In this tutorial, we’ll explore how to dynamically register beans based on custom properties. We’ll explore the BeanDefinitionRegistryPostProcessor interface and how we can use it to add beans to the application context.
2. Code Setup
Let’s start by creating a simple Spring Boot application.
First, we’ll define a bean that we want to register dynamically. Then, we’ll provide a property that decides how to register the beans. And finally, we’ll define a configuration class that will register the bean based on our custom properties.
2.1. Dependencies
Let’s start by adding the Ma ..read more
Baeldung » Spring
1w ago
1. Overview
JSON Web Tokens (JWT) is the de facto standard for securing a stateless application. The Spring Security framework provides methods of integrating JWT to secure REST APIs. One of the key processes of generating a token is applying a signature to guarantee authenticity.
In this tutorial, we’ll explore a stateless Spring Boot application that utilizes JWT authentication. We’ll set up the necessary components and create a cryptographic SecretKey instance to sign and verify the JWT.
2. Project Setup
To begin with, let’s bootstrap a stateless Spring Boot application with Spring Security ..read more
Baeldung » Spring
1w ago
1. Overview
Caching data means our applications don’t have to access a slower storage layer, thereby improving their performance and responsiveness. We can implement caching using any in-memory implementation library like Caffeine.
Although doing this improves the performance of data retrieval, if the application is deployed to multiple replica sets, then the cache is not shared between instances. To overcome this problem, we can introduce a distributed cache layer that can be accessed by all instances.
In this article, we’ll learn how to implement the two-level caching mechanism in Spring. We ..read more
Baeldung » Spring
1w ago
1. Overview
In today’s event-driven architectures, managing data streams effectively is essential. Apache Kafka is a popular choice for this, but integrating it into our applications has its challenges, despite helper frameworks such as Spring Kafka. One major challenge is implementing proper dynamic listener management, which provides flexibility and control that is crucial for adapting to our application’s changing workloads and maintenance.
In this tutorial, we’ll learn how to dynamically start and stop Kafka listeners in Spring Boot applications.
2. Prerequisites
First, let’s import the sp ..read more
Baeldung » Spring
2w ago
1. Introduction
OpenAPI Generator is a tool that allows us to quickly generate client and server code from REST API definitions, supporting multiple languages and frameworks. Although most of the time the generated code is ready to be used with no modifications, there may be scenarios in which we need to customize it.
In this tutorial, we’ll learn how to use custom templates to address these scenarios.
2. OpenAPI Generator Project Setup
Before exploring customization, let’s run through a quick overview of a typical usage scenario for this tool: generating server-side code from a given API defi ..read more
Baeldung » Spring
2w ago
1. Introduction
Spring Security is an extension of the Spring Framework that makes it easy to build common security practices into our applications. This includes things like user authentication and authorization, API protection, and much more.
In this tutorial, we look at one of the many pieces inside Spring Security: the AuthorizationManager. We’ll see how it fits into the larger Spring Security ecosystem, as well as various use cases for how it can help secure our applications.
2. What Is Spring Security AuthorizationManager
The Spring AuthorizationManager is an interface that allows us to ..read more
Baeldung » Spring
2w ago
1. Overview
Documentation is crucial for any piece of code that we intend to share with the world, especially if this code is relatively complex. Good API documentation not only attracts developers to use it but also shows the quality of the product. A company with sloppy written documentation might also have a sloppy written API.
However, developers like writing code for machines, not text for people.
In this tutorial, we’ll explore how to combine writing documentation and writing APIs with Spring REST Docs. We’ll take query parameter documentation as an example.
2. API
Let’s consider a strai ..read more
Baeldung » Spring
2w ago
1. Overview
Spring Security 6 comes with several major changes, including the removal of classes, and deprecated methods, and the introduction of new methods.
Migrating from Spring Security 5 to Spring Security 6 can be done incrementally without breaking the existing code base. Also, we can use third-party plugins like OpenRewrite to facilitate migration to the latest version.
In this tutorial, we’ll learn how to migrate an existing application using Spring Security 5 to Spring Security 6. We’ll replace deprecated methods and utilize lambda DSL to simplify configuration. Also, we’ll utilize O ..read more
Baeldung » Spring
2w ago
1. Overview
Database functions are essential components in database management systems, enabling the encapsulation of logic and execution within the database. They facilitate efficient data processing and manipulation.
In this tutorial, we’ll explore various approaches to calling custom database functions within JPA and Spring Boot applications.
2. Project Setup
We’ll demonstrate the concepts in the subsequent sections using the H2 database.
Let’s include Spring Boot Data JPA and H2 dependencies in our pom.xml:
<dependency>
<groupId>org.springframework.boot</groupId> ..read more