DEV Community

Cover image for ๐Ÿ Preparing for Spring Boot 3.0
adriens for opt-nc

Posted on

๐Ÿ Preparing for Spring Boot 3.0

๐Ÿ‘‰ Context

We all are aware that...

Spring Boot 3.0 is coming โ•

Since a few months as part of our pipeline's migration from onPremise to Github.com process we have been prototyping on Spring Native and invest on maintenance by upgrading :

  • Our dependencies (let Dependabot PRs โ›† ๐Ÿ˜ฑ ), making us upgrade all to 2.6.7, then more recently 2.7.0
  • Our runtime from Java 8 to Java 17... from the dev side up to the server runtime

๐Ÿงฝ Gains

That was a big work to achieve but offered us the opportunity to improve our testing strategies (less code for more coverage), dependencies cleanup/removal to make native easier in a near future.

Notice that this investment made it possible to achieve RUN tasks in a much more comfortable on a continuous pace and less time consuming way... while making it possible to upgrade the middlewares we rely on.

โ˜๏ธ Switching to Spring Data libraries

As part of dependencies cleanup, we switched to Spring Data for Elasticsearch, hence making us rely on Spring Data instead of Elastic's ones.

So we chose the following straightforward strategy :

We did migrate our Elastic instance to Elastic 7... and wait to Spring Boot 3, based on Spring 6 and Java 17.

Image description

Find below the compatibility matrix (so you don't have to look for it ๐Ÿ˜“) :

Image description

๐Ÿณ Docker prepare

In the mean time we also did prepare traditional (non native) docker images that embeds a secured Java 17 runtime, see below for more :

๐ŸŒŒ Be ready for Spring Boot 3

Fortunately Spring tweeted a dedicated post on this topic :

According to the blog post, here are the things you can do to get ready.

In our team, this will be used as a checklist to get ready to migrate as clean as possible :

1๏ธโƒฃ Upgrade to Java 17

"Spring Boot 3.0 will require Java 17."

Hence it makes it possible to use Records.

Also here is Spring advice :

"We highly recommend that you upgrade your JDK today if at all possible."

2๏ธโƒฃ Upgrade to the Latest Spring Boot 2.7.x

Spring will provide a migration guide to Spring Boot 3...

"but it will assume that youโ€™re migrating from Spring Boot 2.7 and not an earlier version."

We also applied the following migration strategy, following SB upgrades on a continuous way (so we finally could drastically reduce our technical debt):

If youโ€™re upgrading from Spring Boot 2.5 or earlier, we donโ€™t recommend skipping releases.** Itโ€™s often easier to upgrade in steps** (e.g. 2.5 โ†’ 2.6 โ†’ 2.7) rather than trying to upgrade directly from 2.5 โ†’ 2.7.

3๏ธโƒฃ Check for Calls to Deprecated Code

Spring Boot 3.0 will remove all deprecated code, so we recommend that you check your existing code is not relying on any deprecated methods. Itโ€™s worth considering using the -Werror Java compiler option to fail your build if deprecation warnings are reported.

4๏ธโƒฃ Migrate from Legacy application.properties and application.yaml Processing

The legacy processing support will not be coming to Spring Boot 3.0 so you should check that your project doesnโ€™t set spring.config.use-legacy-processing.

5๏ธโƒฃ Use Spring MVCโ€™s PathPatternParser

we recommend using the PathPatternParser if at all possible since it provides better performance.

6๏ธโƒฃ Other

Also see the full blog post for more about Third-party Projects Have Jakarta EE 9 Compatible Releases and Third-party Projects have Updated Spring Compatible Releases

๐Ÿ”– Resources

Discussion (2)

Collapse
adriens profile image
adriens Author
Collapse
adriens profile image
adriens Author

Another great news !