What’s new in Spring Boot 2.1

Last Updated:  May 8, 2020 | Published: November 6, 2018

Recently Andy Wilkinson (@ankinson) from the Spring Boot core team announced the release of Spring Boot 2.1. During the last days, I played around with the new version and will present you the most important updates from my point of view.

Support for Java 11

I think the most important update for this new release is the support of Java 11 which was released in September this year and is the latest LTS version of Java. Trying the new features of Java 9, 10 and 11 with just plain Java SE is nice, but without the support of your framework, you can't utilize the features in production. To my knowledge Spring is also the first major Java framework that supports Java 11 and was able to release a production-ready version about one month after Java 11 GA. Bootstrapping a new Spring Boot project with Java 11 will result in the following pom.xml and will out of the box with no additional configuration.

Third-party library upgrades

Spring Boot 2.1 upgrades to the core Spring Framework with version 5.1 which comes with initial refinements for GraalVM, functional bean definitions for Java and Kotlin, improved startup time and less heap memory consumption due to optimizing the internal use of reflection.

Other notable upgrades are the following:

Other news

Logging Groups

We are now able to group different packages for which we want to define a common log level in a so-called logging group. With this you can group e.g. all your business logic related classes into a group and define DEBUG as the log level and TRACE for example for your messaging interfaces which will log all the incoming messages:

There are also to pre-defined logging groups web and sql which are provided out-of-the-box.

Bootstrap mode for JPA setup

Bootstrapping a Spring Boot application with a lot of JPA entities and JPA repositories from Spring Data can influence the startup time of your application. With the Spring Data Lovelace release, they introduced a so-called bootstrap mode where you can define the initialization of the repositories. In the default mode, the full initialization happens during the startup of the application. The deferred mode uses a background JPA infrastructure initialization deferred until the ApplicationContext  has completed its initialization. With lazy you get the JPA infrastructure initialization deferred until the first access:

For a sample project to show the differences, have a look at the following repository: Spring Data JPA – Deferred bootstrap modes

JUnit 5 improvements

With Spring Boot 2.1 you can remove the required @ExtendWith(SpringExtension.class) annotation if you are using a Spring Boot testing annotation @…Test like @DataJpaTest as they are all now meta-annotated with the Spring extension. In addition, you now don't have to do any custom setup for your Maven plugins to make use of JUnit 5.

There are a lot more upgrades and news but these were one of the most useful ones for my projects. You find the full list of news in the official Release Notes on GitHub.

A sample Spring Boot 2.1 project with Java 11 can be found in my GitHub repository.

See you,

Phil

  • {"email":"Email address invalid","url":"Website address invalid","required":"Required field missing"}
    >