What Are the New Features of SpringBoot 3.0 ?

1. Java 17

One of the most important changes that we should be concerned about is that the Spring boot 3.0 supports at least Java 17. Here are some of the most important changes of Java 17.

1.1 Records

In the past, in order to write a class, we need to create a bunch of getters and setters. Later Lombok saved the situation and reduced the code.

Now java gives provides us a native way to write classes

Currently, we need to be careful when combining them with Bean Validation because validation constraints aren't supported on constructor arguments, such as when the instance is created on JSON deserialization (Jackson) and put into a controller's method as a parameter.

1.2 Text block

it's now possible to create multi-line text blocks without the need to concatenate strings on line breaks:it's

1.3 Switch expressions

Switch expressions were introduced in Java12 and made permanent in Java14.

The upgraded switch contains two features, one is to allow the case to use multiple constants, and the other is to have a return value.

The new case x-> syntax is more concise in use, and there is no need to write a break for each case.};

1.4 Sealed classes and Interfaces

Sealed classes can limit inheritance by specifying allowed subclasses.

In short sealed classes gives you the control of which models, classes etc. that can implement or extend that class/interface.

2. Jakarta EE 9

The most important change might be the jump from Java EE to Jakarta EE9, where the package namespace changed from javax.* to jakarta.*. As a result, we need to adjust all imports in our code whenever we use classes from Java EE directly.

3. Spring native

Spring Native is also a major feature of the upgrade. It supports using GraalVM to compile Spring applications into locally executable image files, which can significantly improve startup speed, and peak performance, and reduce memory usage.

Our traditional applications are compiled into bytecode, then interpreted by, JVM and finally compiled into machine code to run, while Spring Native is compiled into machine code in advance through AOT, and statically compiled into executable files directly at runtime. Depends on the JVM.

4. More dependencies upgrades

Spring Framework 6 and Spring Boot 3 need the following minimum versions:

  • Kotlin 1.7+
  • Lombok 1.18.22+ (JDK17 support)
  • Gradle 7.3+

5. Prepare your migration

There are a few hints for project migration that we should know. The recommended steps are:

  1. Migrate to Spring Boot 2.7 first (The migration guide based on Spring Boot 2.7)
  2. Check for deprecated code usage, it will be removed with the new major release
  3. Migrate to Java 17
  4. Check third-party projects to have Jakarta EE 9 compatible releases