Spring Framework 6.0 and Spring Boot 3.0 – Upcoming Changes Overview
With a General Availability release date scheduled for October 2022, it is a tantalizing idea to use Spring Framework 6.0 with or without Spring Boot 3.0 in your new project, or migrate an existing one from the currently used version. As declared by the Spring project team, the new version of the framework intends to introduce changes that will make it “future-proof at the price of initial compatibility breakage.”
The releases will be of much interest in the Java development circles. According to 2021 Spring Framework User Survey, 86% of participating Java developers use Spring Framework or Spring Boot. So take a look at the most important changes announced so far and see how they’ll affect projects based on Spring Framework 6.0 and Spring Boot 3.0.
What’s new in Spring Framework 6.0?
JDK 17 and Jakarta EE 9 baseline
The Spring project team plans to significantly change the baseline Java version – this will set the minimum required version of JDK to a runtime of 17 and necessitate the usage of Jakarta EE 9 compatible web server (such as Tomcat 10 or Jetty 11). This, of course, means a serious upgrade for some of the older projects.
The release of Jakarta EE 9 is a final step in a larger plan of transferring Java EE from Oracle to open-source Eclipse Foundation, which required changing the API package name from javax namespace to jakarta. This will affect packages such as Servlet API, JPA, Bean Validation and many others, and necessitate adjustments in import statements. As specified in the guidelines on upgrading to 6.0, some of the affected classes are annotations, such as @Inject (switch from javax.inject to jakarta.inject), @PostConstruct or @PreDestroy (switch from javax.annotation to jakarta.annotation). Another requirement stated in the guidelines is updating Hibernate ORM to 5.6.x version, which in turn makes it necessary to switch javax.persistence imports to jakarta.persistence.
Miscellaneous changes in Spring 6.0
The aforementioned source code changes are only the more noticeable ones and many minor changes and fixes might appear depending on a particular application. But the bottom line is: introducing jakarta namespace necessitates making changes in import statements, replacing deprecated classes and updating third-party libraries to compatible types.
Another set of changes is connected to dropping out integration with several outdated Servlet-based solutions, such as Commons FileUpload or FreeMarker JSP, which might require a significant rework of web applications that rely on them. Moreover, the Spring-specific class ListenableFuture will be deprecated in favor of CompleteableFuture provided by core Java.
Spring Framework 6.0 will introduce a change in controller detection for Spring MVC and Spring WebFlux. In previous versions, a class annotated only with a top-level @RequestMapping annotation was registered as handler, even without @Controller or @RestController annotation. With Spring Framework 6, @Controller annotation is required.
Spring Native provides support for compiling Spring applications to native images with GraalVM, thus providing a new way to deploy Spring applications.
Spring Framework 6.0 aims at providing core support for Spring Native – the first features will be introduced to the third milestone of Spring Framework 6.0 with more coming in in the future. If you would like to learn more about Spring Native, check out this detailed video provided by the Spring project team.
Spring Boot 3.0 – what you need to know
Changes in properties processing
Spring Boot 2.4 introduced changes in application properties processing – a change that might have been not noticeable for most projects, but in some cases, it was necessary to rely on previous behavior, which can be activated using spring.config.use-legacy-processing property.
In Spring Boot 3.0 legacy properties processing will no longer be supported, therefore projects that use old behavior have to ensure that new properties processing is compatible.
Two important changes will affect Actuator metrics:
Removed auto-configuration for embedded MongoDB
Spring Boot 3.0 will no longer support auto-configuration and dependency management for Flapdoodle embedded MongoDB. Projects that use a Flapdoodle should use an auto-configuration library provided by this project or consider migrating to Testcontainers.
Matching trailing slash in URLs deprecated
Currently, an endpoint registered in controller matches by default the defined path with trailing slash – for example, @GetMapping(“/some/greeting”) will match both /some/greeting and /some/greeting/ paths. In Spring Boot 3 this will no longer be supported by default due to security concerns. The previous behavior can be activated with appropriate configuration, although it is recommended to adjust the web application to use the new approach.
Spring Framework 6 and Spring Boot 3 – Conclusion
The releases of Spring Framework 6 and Spring Boot 3 are mainly aimed at keeping projects up to date with the current state of Java ecosystems, mainly the release of Jakarta EE 9 and the transfer of this project from Oracle to Eclipse Foundation. While this is a core point of this release, it also brings changes that might affect certain existing projects, and introduces new parts of Spring ecosystem to a broader audience (Spring Native). All in all, the main goal is to brush up the foundations of the framework and provide access to the latest Java baseline, which is certainly peaking users’ curiosities.
Keeping up with new framework releases is a crucial element of maintaining software. For a product to be both successful and secure, engineers need to keep their finger on the pulse of new developments in their technologies of choice. At Software Mind, we stay on top of cutting-edge solutions to help industry leaders gain a competitive edge. If you’re looking for a software development team that will reliably support you with their tech expertise, contact us by filling out this form.