Posts

New features in Spring Boot 3.3

May 23, 2024
Dmitry Chuyko
6.2

Spring Boot 3.3 is generally available! The release includes numerous updates, including several new features. We have decided to do some cherry-picking and take a look at the most significant changes, among which the support for Class Data Sharing (CDS) for faster application startup.

New Service Connections

Several service connections were improved in or added to Spring Boot:

  • Added support for Apache ActiveMQ Artemis;
  • Added support for the apache/activemq-classic docker image and the ActiveMQContainer testcontainer to the ActiveMQ service connection;
  • Added service connection support for LDAP with the osixia/openldap container;
  • Spring Boot Docker Compose will detect and configure Bitnami containers in addition to official images for several technologies, including but not limited to Elasticsearch, MongoDB, and PostgreSQL.

CDS Support

Class Data Sharing (CDS) is a JVM feature that helps to minimize the startup of a Java application by creating the archive of already initialized classes, which can be used for further application launches and even shared between JVM instances.

Spring Boot already supports extracting layers from the application uber jar with the help of -Djarmode=tools (which supersedes -Djarmode=layeredtools), which enables the developers to accelerate docker pull and container image updates. As far as CDS is concerned, Spring Boot offers a convenient way to create a CDS archive for application (AppCDS) on application exit when you specify two JVM flags:

  • -XX:ArchiveClassesAtExit=application.jsa to create the CDS archive;
  • -Dspring.context.exit=onRefresh to start and immediately exit the application.

As a result, the process exits automatically once the ApplicationContext has refreshed, but the lifecycle hasn’t started yet. 

To create a CDS archive for the application, your JDK must have a base image. To minimize the effort of creating a base CDS archive for JVM, you can use a prepared container image with Liberica JDK and system CDS. This way, you don’t have to use special commands to generate a CDS archive. To use Liberica JDK containers with CDS, visit our Docker Hub repository and select an image with a cds tag.

If reducing the application startup time is crucial to you, CDS may be perceived as a go-between for the standard JVM and innovative solutions such as Coordinated Restore at Checkpoint (CRaC) and GraalVM Native Image. There’s no need to change the application code to use CDS, but you may need to adjust the runtime settings and consider several important aspects (such as that the classpath and JVM version must be the same as the ones used when building the archive).

We believe that using CDS with Spring Boot apps has exciting prospects, and this topic deserves a separate article, which it is coming soon! You can subscribe to our newsletter so as not to miss it.

Auto-configuration of Embedded Web Server SSL with SNI

Server Name Indication (SNI), an extension to the TLS protocol that enables the specification of a domain name the client device tries to reach, is now supported when configuring an embedded web server (Tomcat, Netty, or Undertow). Multiple hostnames with unique SSL trust material can be configured declaratively through spring.ssl.bundle properties in the .properties or .yaml file.

Other important improvements

Observation

The following improvements were delivered to Spring Boot observability capabilities:

  • Added support for Micrometer @SpanTag annotation, which enables you to add tags for custom spans;
  • It is now possible to use properties to enable observations for the simple, direct, and stream listener and on the RabbitTemplate;
  • Added support for tagged fields for Brave and OpenTelemetry and support for local fields for Brave;
  • unknown_service is used for OpenTelemetry if no application name is specified to align with the OpenTelemetry specification;
  • Changed the default value for the spring.pulsar.listener.observation-enabled and spring.pulsar.template.observations-enabled properties from true to false;
  • Implemented a new JDK HttpClient based Zipkin sender;
  • Updated Brave to 6.0 and Zipkin to 3.0. 

Support for Prometheus Client 1.x

Spring Boot 3.3 supports Prometheus Client 1.x. Prometheus Client 1.0.0 was a long-expected release of a popular Java metrics library as it includes some ground-breaking changes including but not limited to built-in support for native histograms, seamless integration with OpenTelemetry tracing, and support for OpenTelemetry Exporter.

SBOM Actuator Endpoint

The spring-boot-actuator module now includes a SBOM endpoint. In addition, the spring-boot-parent-starter includes additional configuration for a more convenient configuration of SBOM plugins.



More detailed information about other fixes and enhancements can be found in Release Notes.

Subcribe to our newsletter

figure

Read the industry news, receive solutions to your problems, and find the ways to save money.

Further reading