What's new in Spring?
Russia has invaded Ukraine and already killed tens of thousands of civilians, with many more raped and tortured. Ukraine needs your help!
If you feel a little overwhelmed with the constant stream of news from the Spring team - I hear you. November was a very hot month for Spring developers. In addition to plenty of Spring project portfolio releases there were few interesting changes that you might have missed.
Below I collected the most important things (and added some notes) that I believe you - as a Spring developer - should know to stay up to date.
Just to avoid any confusion - I do not work for Spring/VMWare and this is not an official news blog post by any means. For the official news from the Spring team follow weekly series "This week in Spring" written by Josh Long at https://spring.io/blog.
- New Releases
- Changes at start.spring.io
- SpringOne switched to an online event
- Logo change on spring.io website
1. New Releases
1.1 Spring Framework 6.0
Spring Framework has become a foundation for all the other Spring modules, so often we don't follow much what has changed as we are more interested in how Spring Boot offers these changes to be consumed by developers.
There are though some both important and interesting changes you should get familiar with.
Official announcement: 👉 Spring Framework 6.0 goes GA at spring.io/blog
"Introducing Spring Framework 6.0" by Brian Clozel and Stephane Nicoll:
1.1.1 GraalVM Native Image Support
It is possible now to compile and build Spring Framework based projects to GraalVM Native Image - thanks to which applications have not only dramatically shorter startup times but also consume much less memory.
This capability has been developed for past 3 years in an experimental project called Spring Native - now it has been merged into Spring Framework 6 and Spring Boot 3 effectively ending the life of the Spring Native project.
While it may sound reasonable to switch completely to building native images instead of running Spring applications on JVM - in many cases it is not, for reasons explained in Spring Boot 3 Native Image - Not a Free Lunch. Also, there is a chance that the dependencies you use do expose required metadata for GraalVM and you either have to ditch them, change the way they are used, or just wait until the become GraalVM native image friendly.
Especially if you are going to build a new application I recommend getting familiar with the constraints to see how your use case fits and consider targeting native build.
1.1.2 HTTP Interfaces
Spring now offers creating HTTP clients in a declarative way in a feature called HTTP interfaces.
This is not a new concept - it has been possible to do it in Spring since years through Spring Cloud OpenFeign project. Now it is a first class citizen and I imagine we can expect better support and integration with other aspects of a framework than through 3rd party options.
Distributed tracing capability for Spring stack that used to live in Spring Cloud Sleuth project, has moved to Micrometer Tracing and also became Spring Framework's dependency. Effectively, when using Spring Framework 6 (or Spring Boot 3 for that matter), you should not include anymore the dependency to Spring Cloud Sleuth.
I recommend reading a fantastic post by Marcin Grzejszczak - Observability with Spring Boot 3 and Micrometer Tracing documentation to learn what's the Spring approach to observability defined as interconnection between metrics, logging, and distributed tracing.
1.1.4 Migration from javax to jakarta
Due to political reasons many of the modules that used to reside in
javax package has been moved to
jakara package. Spring team has nothing to do with this change and just had to adjust to the reality.
As a result, all the classes from packages like
javax.persistence moved to
jakarta.persistence respectively. Be prepared to spend some time on "Find & Replace" in your IDE.
1.1.5 Upgrading baseline to Java 17
Spring has been compatible with Java 17 since a long time, so this does not mean that now you can use Java 17 and before you couldn't. It means though that now Spring Framework uses internally Java 17 and requires Java 17 or newer in your projects.
I think this is great from the adoption point of view as it will effectively force developers to upgrade Java versions (which will positively affect applications performance and developers' happiness) but in case you are stuck for whatever reason with Java 11 or Java 8 - you have a problem - as you won't be able to use Spring Framework 6 and any Spring module based on Spring Framework 6.
1.2 Spring Data 2022.0
Spring Data is an umbrella for all datastore specific projects so for each one it brings a different set of changes. To be honest, I don't find it easy to go through changelogs and find what exactly has changed between the major version.
For the Spring Data JPA, definitely the highlight is upgrade to Hibernate 6. You can learn more about upgrading to Hibernate 6 and Spring Framework 6 from the Vlad's article with a bit clickbaity title The best way to do the Spring 6 migration.
Also, a new repository type has been introduced -
ListCrudRepository, and a couple of things have changed in regard to
PagingAndSortingRepository. I recommend learning more about the changes and reasons from the official blog post Announcing ListCrudRepository & Friends for Spring Data 3.0.
1.3 Spring Modulith 0.1
Spring Modulith is a new, experimental Spring project that supports developers in expressing these logical application modules in code and in building well-structured, domain-aligned Spring Boot applications.
(from Introducing Spring Modulith by Oliver Drotbohm)
This effectively means that it gives tools to enforce internal structure within single (monolithic) application - split it into modules with clearly expressed dependencies, test these modules independently and enforce module boundaries with tests.
- Introducing Spring Modulith
- Spring Modulith Structures Spring Boot 3 Applications with Modules and Events
1.4 Spring Authorization Server 1.0
A new Spring module for implementing OAuth2 authorization server. This somewhat reverses the decision to remove authorization server capabilities from Spring Security.
Now, Authorization Server is completely detached from Spring Security and functions as a separate Spring module.
👉 Spring Authorization Server 1.0 is now GA
I recommend watching a talk from Laur Splica on this very topic:
2. Changes in start.spring.io
2.1 Gradle is the default build tool
Spring team took a quite controversial decision to switch the default build tool at start.spring.io from Maven to Gradle.
... which caused some drama on Twitter (that I actually enjoyed). I recommend looking into https://github.com/spring-io/start.spring.io/issues/1012 and go through the discussion to get familiar with different pros/cons of using Gradle and Maven.
If you don't like having Gradle selected by default, I made a Chrome extension that reverts this change.
2.2 Gradle Kotlin variant for Java projects
It is possible to choose which flavor or Gradle build to use - Groovy or Kotlin (not determined by the language as it used to be).
3. SpringOne switched to online event
Unexpectedly, one month before the SpringOne was meant to happen, the event has transitioned into a free virtual event and rescheduled to January. A bummer for everyone who planned their trip to San Francisco but on the other hand everone around the globe will be able to attend the virtual variant of this event for free.
It won't be a full-fledged conference like SpringOne in pandemic times, but rather a series of presentations on the latest and greatest in Spring ecosystem directly from the Spring team.
4. Logo change on spring.io website
A subtle change at spring.io website - the Spring logo got decorated with "by VMWare Tanzu".
Perhaps it is a cosmetic change, or maybe it means something more. Time will tell.