Spring Boot 3.2, the latest release of the popular Java web framework. Spring Boot 3.2 introduces many new features and improvements that make web development easier and more enjoyable. In this blog, I will give you an overview of some of the highlights of Spring Boot 3.2 and show you how to get started with it.
What is Spring Boot?
Spring Boot is a framework that simplifies the creation and deployment of Spring-based applications. It provides a set of tools and conventions that help you to:
- Configure your application with minimal or no XML
- Embed a web server such as Tomcat, Jetty, or Undertow
- Manage dependencies and versions with Spring Boot Starter dependencies
- Create executable JAR or WAR files with the Spring Boot Maven or Gradle plugins
- Monitor and manage your application with Spring Boot Actuator endpoints
- Test your application with Spring Boot Test support
Spring Boot is designed to work well with other Spring projects, such as Spring Data, Spring Security, Spring Cloud, and Spring WebFlux. You can also use Spring Boot with other popular technologies, such as MongoDB, Kafka, RabbitMQ, GraphQL, and more.
What’s new in Spring Boot 3.2?
Spring Boot 3.2 adds a significant number of new features and improvements, such as:
Support for Virtual Threads
Spring Boot 3.2 supports running your application with virtual threads, also known as fibers or project Loom, when using Java 21 or later. Virtual threads are lightweight threads that can run on a small number of kernel threads, improving concurrency and scalability. You can enable virtual threads by setting the spring.main.virtual-threads property to true in your application.properties file.
Initial support for JVM Checkpoint Restore (Project CRaC)
Spring Boot 3.2 provides initial support for JVM Checkpoint Restore, also known as project CRaC, which allows you to save and restore the state of your application across JVM restarts. This can be useful for fast application startup, migration, or disaster recovery. You can use the spring.crac.checkpoint and spring.crac.restore properties to enable checkpoint and restore operations in your application.properties file.
SSL Bundle Reloading
Spring Boot 3.2 allows you to reload your SSL bundle without restarting your application, which can be useful for certificate rotation or renewal. You can enable SSL bundle reloading by setting the server.ssl.bundle-reload.enabled property to true in your application.properties file. You can also specify the reload interval with the server.ssl.bundle-reload.interval property.
A lot of Observability Improvements
Spring Boot 3.2 improves the observability of your application by providing more metrics, traces, and logs. For example, you can now collect metrics for handler methods, Spring Data repositories, reactive codecs, and more. You can also use the new logging.observability.enabled property to enable structured logging with JSON format. You can also integrate your application with popular observability platforms, such as Prometheus, Grafana, Zipkin, and more.
Support for RestClient
Spring Boot 3.2 provides auto-configuration for Spring Framework’s new RestClient, which is a declarative and reactive HTTP client that supports HTTP/2, HTTP/3, and gRPC protocols. You can use the @RestClient annotation to create RestClient beans and use them to make HTTP or gRPC calls. You can also customize your RestClient beans with the RestClientCustomizer interface or the RestClientBuilder class.
Support for JdbcClient
Spring Boot 3.2 provides auto-configuration for Spring Framework’s new JdbcClient, which is a reactive and transactional JDBC client that supports R2DBC drivers. You can use the @JdbcClient annotation to create JdbcClient beans and use them to execute SQL queries or commands. You can also customize your JdbcClient beans with the JdbcClientCustomizer interface or the JdbcClientBuilder class.
Support for Jetty 12
Spring Boot 3.2 supports running your application with Jetty 12, which is the latest version of the popular web server that supports HTTP/3 and gRPC protocols. You can use the spring-boot-starter-jetty dependency to use Jetty as your embedded web server and configure it with the server.jetty.* properties in your application.properties file.
How to get started with Spring Boot 3.2?
To get started with Spring Boot 3.2, you can use one of the following options:
Spring Initializr
Use the Spring Initializr https://start.spring.io/ to generate a Spring Boot project with your preferred dependencies and settings. You can choose Spring Boot 3.2 as your Spring Boot version and select the starters that you want to use, such as spring-boot-starter-web, spring-boot-starter-data-jpa, spring-boot-starter-actuator, and more. You can also choose your build tool, language, packaging, and Java version. You can then download and unzip the project and import it into your IDE of choice.
Spring Boot CLI
Use the [Spring Boot CLI] to create and run Spring Boot applications from the command line. You can install the Spring Boot CLI with Homebrew, SDKMAN, or manually. You can then use the spring init command to generate a Spring Boot project with your preferred dependencies and settings. You can also use the spring run command to run your Spring Boot application from a source file or a directory.
Spring Boot Maven or Gradle plugins
Use the [Spring Boot Maven or Gradle plugins] to create and run Spring Boot applications with your existing build tool. You can add the Spring Boot plugin to your pom.xml or build.gradle file and configure it with your preferred dependencies and settings. You can then use the mvn spring-boot:run or gradle bootRun command to run your Spring Boot application from your project directory.
Spring Boot 3.2 is a major release that brings many new features and improvements to the Spring Boot framework. It makes web development easier and more enjoyable by simplifying the configuration, deployment, and management of Spring-based applications. It also supports the latest technologies and standards, such as virtual threads, JVM checkpoint restore, SSL bundle reloading, observability, RestClient, JdbcClient, Jetty 12, and more. If you want to learn more about Spring Boot 3.2, you can check out the [official documentation]
Thank you for reading this blog and I hope you enjoy using Spring Boot 3.2. Happy coding! blush