Spring Cache Redis uses SCAN instead of KEYS to match the key to be evicted in bulk

When spring-cache uses redis as the cache implementation, if the cache is deleted in bulk via @CacheEvict(allEntries = true), the KEYS command of redis is used by default to match the keys to be deleted. Example of using KEYS Define a cache implementation class that removes all eligible caches via the @CacheEvict(allEntries = true) annotation. 1 2 3 4 5 6 7 8 import org.springframework.cache.annotation.CacheEvict; import org.springframework.stereotype.Component; @Component public class FooCache { @CacheEvict(cacheNames = "app::cache", allEntries = true) public void clear () {}; } Run the test method, execute the clear method, and observe the output log.

Spring Boot 3 Upgrade Guide

Spring Boot 3.0 is now available and includes more than 5,700 code commits from 151 developers over 12 months. This is the first major revision of Spring Boot since the release of 2.0 4.5 years ago. It is also the first Spring Boot GA release to support Spring Framework 6.0 and GraalVM, and the first Java 17-based version of Spring Boot, benchmarked against Jakarta EE 9 and supporting Jakarta EE 10.

Spring Framework 6.0 official GA, the beginning of a new generation of frameworks

Spring Framework 6.0.0 is now available. This is the start of a new framework generation for 2023 and beyond, embracing current and upcoming innovations in OpenJDK and the Java ecosystem. At the same time, we carefully designed it as a straightforward upgrade from Spring Framework 5.3.x for modern-day runtime environments. As a major revision to the core framework, Spring Framework 6.0 brings the Java 17+ baseline and migration to Jakarta EE 9+ (in the jakarta namespace) with a focus on the recently released Jakarta EE 10 APIs such as Servlet 6.

Spring Native builds native images without Graal's maven plugin buildtools

Create a Spring Boot project Create a Spring Boot project and add Spring Native dependencies, we are mainly using the AOT functionality provided by Spring Native. As follows. 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 <dependencies> <dependency> <groupId>org.springframework.experimental</groupId> <artifactId>spring-native</artifactId> <version>${spring-native.version}</version> </dependency> <dependency> <groupId>org.

Spring Boot 3 Observability with Grafana

This article will teach you how to configure observability for your Spring Boot applications. We assume that observability is understood as the interconnection between metrics, logging, and distributed tracing. In the end, it should allow you to monitor the state of your system to detect errors and latency. There are some significant changes in the approach to observability between Spring Boot 2 and 3. Tracing will no longer be part of Spring Cloud through the Spring Cloud Sleuth project.

Kafka Transactions with Spring Boot

In this article, you will learn how to use Kafka transactions with the Spring Kafka project in your Spring Boot app. In order to run the Kafka cluster we will use Upstash. This article provides a basic introduction to Kafka transactions. If you are looking for more advanced usage and scenarios you may refer to that article, about distributed transactions in microservices. You can also read more about Kafka Streams the Spring Cloud Stream project in this article.

Production Considerations for Spring on Kubernetes

The State of Spring on Kubernetes The 2021 State of Spring report has two main data points: Spring is the defacto standard for running cloud-native applications in Java. Kubernetes is the defacto standard for running containerized workloads in production. This begs the question - what kind of best practices and considerations should be taken into account when running Spring on Kubernetes? In this article, I shall highlight some of the learnings and best practices that have formed around running Spring (and more broadly Java) applications on Kubernetes.

Spring Boot 3.0.0 First RC Release

The first RC of Spring Boot 3.0 has been released, along with updates for two branches: 2.7.5 & 2.6.13. 3.0.0-RC1 The release announcement states that this version contains 135 feature enhancements, documentation improvements, dependency upgrades and bugfixes. Development of Spring Boot 3.0 began with the experimental Spring Native, designed to provide support for GraalVM native images. In this release, developers can now convert Spring Boot applications to native executables using the standard Spring Boot Maven or Gradle plug-ins without any special configuration.

What is aot.factories in Spring 6?

Some of the changes in Spring 6.0, in addition to some of the dependency package adjustments, it seems like not much change. Today I’ll take you deep into the source code to explore the biggest change - the new Graalvm aot support. 1. Spring core Spring framework 6.0 has a major change to Spring core with the addition of the following directories. GraalVM feature – GraalVM allows clients to intercept native images to generate and run custom code at different stages of initialization.

Fix Undertow outputting warning logs on Spring Boot startup

Using Undertow as a Servlet Container Spring Boot uses Tomcat as the Servlet container by default, but Undertowis gradually gaining more popularity for its excellent performance. To use Undertow instead of Tomcat in Spring Boot, simply exclude spring-boot-starter-tomcat from the spring-boot-starter-web starter and add the spring-boot-starter-undertow dependency. 1 2 3 4 5 6 7 8 9 10 11 12 13 14 <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-web</artifactId> <exclusions> <exclusion> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-tomcat</artifactId> </exclusion> </exclusions> </dependency> <dependency> <groupId>org.

Embracing Virtual Threads

Project Loom has made it into the JDK through JEP 425. It’s available since Java 19 in September 2022 as a preview feature. Its goal is to dramatically reduce the effort of writing, maintaining, and observing high-throughput concurrent applications. Where Virtual Threads make sense This makes lightweight Virtual Threads an exciting approach for application developers and the Spring Framework. Past years indicated a trend towards applications that communicate over the network with each other.

How to Deploy Spring Boot Applications to Tomcat Application Server

We sometimes encounter a variety of application servers to deploy in our projects due to the different customers we work with. Although Spring Boot has a built-in Embedded Tomcat server, this is mainly used for development or microservice deployment. If you end up deploying your application to a client’s Tomcat / JBoss EAP / IBM WebSphere environment, you still need to make some adjustments. Today’s article is an in-depth look at the setup process and complete knowledge of deploying to Apache Tomcat®.

Native Support in Spring Boot 3.0.0-M5

The Spring Team has been working on native image support for Spring Applications for quite some time. After 3+ years of incubation in the Spring Native experimental project with Spring Boot 2, native support is moving to General Availability with Spring Framework 6 and Spring Boot 3! Native images provide almost instant startup time and reduced memory consumption for Java applications. The recent Spring Boot 3.0.0-M5 release marks the first time we’re asking for broader community feedback on our native story.

Spring Profiles in Spring Boot

In any set of development frameworks, multi-environment management is usually one of the important core features, of course, in the Spring framework is no exception, here we call the Spring Profiles. This feature is simple to say, but it is easy to accidentally mess up the implementation, this article I intend to properly sort out some of the concepts to understand, the management up to not mess up. Create sample applications Quickly building a project using the Spring Boot CLI

PathPattern In Spring MVC

Spring 5 has also been out for a long time, there are some new things we need to explore slowly. Recently, when I was looking at the SpringMVC source code, I saw the following piece of code. 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 /** * Initialize the path to use for request mapping. * <p>When parsed patterns are {@link #usesPathPatterns() enabled} a parsed * {@code RequestPath} is expected to have been * {@link ServletRequestPathUtils#parseAndCache(HttpServletRequest) parsed} * externally by the {@link org.

@SpringBootApplication in Spring Boot

When I’m learning a new framework, I like to look at things that beginners don’t like to read or don’t understand. For example, when I was learning Angular, it was obvious that ng new would be enough to create a new project and start writing programs, but I would go deeper into the whole process of starting it. And when I was learning Spring Boot, even though Spring Initializr was really nice to use, and I could start developing applications by just selecting the packages, I wanted to understand what was going on behind the scenes of this amazing design, so I could understand the core principles of a framework.

Formatting json Date/LocalDateTime/LocalDate in Spring Boot

Spring Boot uses jackson by default to serialize, deserialize json data. By default, Jackson serializes Date objects as timestamps. For LocalDateTime, LocalDate objects, jackson doesn’t do anything special, it just treats them as basic Java objects. 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 import java.time.LocalDate; import java.time.LocalDateTime; import java.util.Date; import java.util.HashMap; import java.util.Map; import com.

Getting started with your first spring boot application from scratch

Spring Boot has been gaining traction in the Java community for a few years now, but instead of reinventing the wheel, it has integrated a bunch of good, off-the-shelf packages and designed some simple programming frameworks with IoC and AOP to greatly simplify the complexity of development and reduce the number of tedious setup steps. Instead of using Spring Initializr to get you started, I’m going to completely hand-carve the Spring Boot application and dissect the entire development and startup process from scratch.

Map a JSON POST to Multiple Spring MVC Parameters

1. Overview When using Spring’s default support for JSON deserialization, we’re forced to map the incoming JSON to a single request handler parameter. Sometimes, however, we’d prefer a more fine-grained method signature. In this tutorial, we will learn how to use a custom HandlerMethodArgumentResolver to deserialize a JSON POST into multiple strongly-typed parameters. 2. The Problem First, let’s look at the limitations of Spring MVC’s default approach to JSON deserialization.

Setup of spring boot application & initialization of PostgreSQL database on Kubernetes

Reference Setup of spring boot application & initialization of PostgreSQL database on Kubernetes - PART 1 Setup of spring boot application & initialization of PostgreSQL database on Kubernetes - PART 2 How to deploy a containerized spring boot application , with PostgreSQL as database on minikube. This post will also share details on how to initialize the database with tables and data during the initialization process. Will use a spring boot application order service with a REST endpoint to fetch customer details