What’s new in Spring Boot 3?

What’s new in Spring Boot 3?

In this article, we will explore the exciting new features introduced in Spring Boot 3, the latest version of the popular Java framework. Spring Boot has revolutionized the way developers build Java applications by providing a streamlined and opinionated approach to application development. With each new release, Spring Boot continues to evolve and improve, empowering developers to create robust and scalable applications with ease.

Staying up-to-date with the latest versions guarantees access to new features, enhancements and security improvements, as well as community support, enabling developers to build high-quality applications efficiently.

Summary

1. Overview of Spring Boot 3 

Spring Boot is a widely used framework for developing web applications and microservices in Java. It simplifies the development process by providing intelligent default configurations and eliminating repetitive tasks. Spring Boot accelerates application development by offering built-in features such as integrated application servers, dependency management and out-of-the-box support for many popular libraries and technologies.

Spring Boot 3 is a major release of the Spring Boot framework, released in November 2022. It includes several new features, improvements and bug fixes:

2. Enhancements

Spring Boot 3 introduces various performance enhancements and optimizations to boost application responsiveness and efficiency.

These improvements focus on reducing startup times, minimizing memory footprint, and optimizing resource utilization.

With a more streamlined and lightweight runtime environment, applications built on Spring Boot 3 will experience improved scalability and responsiveness, resulting in a better user experience and higher customer satisfaction.

We will mention one easy way to boost a spring boot application’s performance just below.

3. System requirements

Spring Boot 3 requires Java 17 (or above) and Spring Framework 6 (or above).

Build tools

Maven ➜ 3.5+

Gradle ➜ 7.x (7.5 or later)

Servlet containers

Spring Boot supports the following embedded servlet containers:

NameServlet Version
Tomcat 10.05.0
Jetty 11.05.1
Undertow 2.2 (Jakarta EE 9 variant)5.0
You can also deploy spring boot applications to any servlet 5.0+ compatible container.

GraalVM Native Images

Spring Boot applications can be converted into a Native Image using GraalVM 22.3 or above.

Images can be created using the native build tools Gradle/Maven plugins or the native-image tool provided by GraalVM. You can also create native images using the native-image Paketo build pack.

The following versions are supported:

NameVersion
GraalVM Community22.3
Native Build Tools0.9.18

4. Compatibility and Migration

Migrating to Spring Boot 3 requires a series of associated migrations and dependency updates that must be carried out before upgrading to this latest version of Spring Boot. These include:

There are instances when we may not need to refactor package names when upgrading our software, as some dependencies such as javax.sql.DataSource already belongs to JDK 17, not Jakarta EE. In these cases, it is not necessary to make any changes to the package name, as it is already consistent with the latest version of our app. It is important to note, however, that it is essential to thoroughly review and test all dependencies to ensure that they are compatible with the new version of the code.

Lastly, depending on which version of Spring Boot your applications are being migrated from, there may be a need to make several required changes to both the application’s code and configuration when moving to Spring Boot 3.

5. New Tools and Framework Integrations

5.1. Java 17 Baseline and Java 19 Support

The most important news we are concerned about is that Spring Boot 3 supports Java 17 at least.

If you are currently working with Java 8 or 11, you will need to migrate to JDK 17 before enjoying Spring Boot 3 application development.

Spring Boot 3 also works well and has been tested with JDK 19.

According to the Java Community and the experts:

You might like to read about the new features available in JDK 17.

5.2 GraalVM Native Image Support

With Spring Boot 3, you can now use GraalVM native image support.

Spring Boot 3 applications can now be converted into GraalVM native images which can provide significant memory and startup-up performance improvements.

Say goodbye to your JVM And enjoy the major engineering effort undertaken across the entire Spring portfolio!

To get started with GraalVM native images, please visit the updated Spring Boot reference documentation.

5.3. Jakarta EE API

Spring Boot 3 has migrated from Java JEE to Jakarta JEE APIs for almost all dependencies.

The new compatible dependencies of Jakarta JEE are coming through Jakarta JEE 10, including :


You might like to read about the Jakarta JEE 10 core profile.

5.4 Spring Framework 6

Spring Boot 3 builds on and requires Spring Framework 6. In this release, there are several Spring upgraded modules such as :

We should mention that Spring Framework 6 is now compatible with the JPA support for Hibernate ORM 6.1.

5.5 Web Flux Enhancements

Spring Framework 6 provides us with new enhancement in the WebFlux Spring Module for reactive programming :


You might like to read about the new WebFlux Spring module.

5.6 Micrometer Metrics & Tracing Updates

As we know, Micrometer is the metrics and tracing collection facade of a springboot application that uses Actuator.

SpringBoot 3 comes with two major updates introduced in Micrometer 1.10:

 So, SpringBoot 3 offers us the ObservationRegistry interface that can be implemented to create observation which provides a single API for both metrics and traces.

You might like to read about micrometer metrics and tracing with Actuator Spring Boot 3

5.7 Dependency upgrades

As discussed above, SpringBoot 3 depends on the Spring Framework 6 version at least so other dependencies are upgraded as follows:

5.8 Miscellaneous

These are also some improvements and deprecations in SpringBoot 3.

Improvements:

Depreciations:

6. Security Enhancements

In this section, we will discuss the security-related updates in Spring Boot 3.

6.1 WebSecurityConfigurerAdapter removed

In previous versions of Spring Security, When we wanted to configure the Security settings, we had to extend the WebSecurityConfigurerAdapter class.

This class has been deprecated and removed in Spring Security 6.

Instead, we should now take a more component-based approach and create a bean of type SecurityFilterChain.

Example:

SecurityFilterChain

6.2 authorizeHTTPRequests

Instead of using authorizeRequests, which has been deprecated, we should now use authorizeHttpRequests.

This method is part of the HttpSecurity configuration and allows you to configure fine-grained request matching for access control.

Example:

In this example, we allow access to the “/api/auth” request, while requiring authentication for all other requests.

6.3 requestMatchers replacing antMatchers, mvcMatchers & regexMatchers

In Spring Security 6AntMatcherMvcMatcher, and RegexMatcher have been depreciated and replaced by requestMatchers or securityMatchers for path-based access control. This allows us to match requests based on patterns or other criteria without relying on specific matchers.

In the previous example, we can see that the system permits access to the “/api/auth” endpoint without authentication while requiring authentication for all other requests.

7. Community and Ecosystem

Find below the respective links for:

Conclusion

Spring Boot 3 is a major release that introduces several new features and improvements, including:

These new features and improvements make Spring Boot 3 a more powerful and versatile framework for developing Java applications. They also make it easier to build applications that are more efficient, scalable, and secure.

If you are currently using Spring Boot, you should consider upgrading to Spring Boot 3 to take advantage of these new features and improvements. If you are new to Spring Boot, Spring Boot 3 is a great starting point for building your next Java application.

More Resources

To learn more about Spring Boot and how to implement & use Redis cache, you can take a look at our insights Redis Cache in Spring Boot applications or Distributed Caching using Redis in Spring Boot applications.

Read more Insights on Software Product Engineering.

Newsletter Subscription