DEV Community

Cover image for What’s New in Spring Boot 3 for Java Developers in 2023
Brilworks Software
Brilworks Software

Posted on • Originally published at brilworks.com

What’s New in Spring Boot 3 for Java Developers in 2023

A guide to the latest Spring Boot versions, as well as the addition of new features and enhancements to the latest update.

The Spring team released Spring Boot 3 in November 2022; it includes GraalVM native image support, enhanced Log4j2, Improved @ConstructorBinding, and a handful of new features. This article examines what’s new for Java web development in Spring Boot 3.

What is Spring Boot?
It is an open-source Java development framework that incorporates conventional Spring MVC features allowing developers to leverage Spring framework’s functionalities. If we talk about features, it has robust tools for developing production-grade, robust, asynchronous, and non-blocking web apps. In addition to this, developers can explore a range of configured templates, pre-built modules for services, and security, allowing developers to developer to develop applications at a faster pace.

The Spring Boot 2.X line was a remarkable journey for Java developers as it delivered 95 distinct releases and new functionalities throughout its 4-year timeframe. Nonetheless, the Spring team has ensured open-source support for the 2.7 version until November 2023, and commercial support will continue till 2025.

What’s New in Spring Boot 3?
Moving on to the new features, Spring Boot 3 has some significant additions, including GraalVM native image support, which optimizes application performance. Developers can leverage this new feature to create native images for their Spring Boot applications, leading to faster startup times and lower memory footprints. Additionally, the latest version includes several other updates and enhancements that improve the development experience and provide a better user interface.

1. GraalVM Native Image Support
Furthermore, it’s worth noting that Spring Boot 3 now supports GraalVM native images. This development allows developers to convert Spring Boot applications into native images that have a lesser memory footprint and faster compilation.

For those who don’t know, GraalVM is a runtime environment that allows for the faster execution of Java code. You can learn more about GraalVM in Spring by exploring the resources available here.

2. Log4j2 enhancement
Log4j2, the logging tool available in the Spring Boot framework, includes a few incremental improvements, which are as follows:

  • Profile-specific Configuration
  • Environment Properties Lookup
  • Log4j2 System Properties For more details, you can check the documentation page.

3. Improved @ConstructorBinding Detection
These improvements in constructor binding will make it easier to use constructor binding with @ConfigurationProperties classes and simplify the code.

  • When you use constructor-bound @ConfigurationProperties, Spring Boot no longer requires the @ConstructorBinding annotation if the class has a single parameterized constructor. However, if you have more than one constructor, you still need to use @ConstructorBinding to inform Spring Boot which one to use.
  • For most users, this updated logic will allow for simpler @ConfigurationProperties classes. However, if you have a @ConfigurationProperties and want to inject beans into the constructor rather than binding it, you’ll now need to add an @Autowired annotation.

4. Micrometer Updates
Micrometer, a monitoring tool for Spring applications, includes several enhancements and improvements.

  • Auto-configuration for Micrometer Observation API
  • Auto-configuration for Micrometer Tracing
  • Auto-configuration for Micrometer’s OtlpMeterRegistry

5. Prometheus Support
In Spring Boot 3, Auto-Configuration for Prometheus Exemplars and Push Gateway can be configured to perform a PUT on shutdown. Furthermore, Spring Boot has deprecated the existing push setting and now recommends using post instead.

6. Miscellaneous

  • Auto-configuration for the new Elasticsearch Java Client has been introduced.
  • Apache HTTP client a JdkClientHttpConnector will now be auto-configured
  • The @SpringBootTest annotation can now use the main of any discovered @SpringBootConfiguration class if it’s available. This means that tests can now pick up any custom SpringApplication configuration performed by your main method.

Deprecations in Spring Boot 3.0

  • JsonMixinModule scanning-based constructor has been deprecated, and ClientHttpRequestFactorySupplier is replaced with ClientHttpRequestFactories.
  • Cookie comment properties are now no longer supported.
  • RestTemplateExchangeTagsProvider, WebClientExchangeTagsProvider, WebFluxTagsProvider, WebMvcTagsProvider, and related classes have been replaced with ObservationConvention equivalents.
  • The no-args constructors on HealthContributor @Configuration base classes have been deprecated.
  • DefaultTestExecutionListenersPostProcessor and SpringBootDependencyInjectionTestExecutionListener have been deprecated in favor of Spring Framework’s ApplicationContextFailureProcessor.
  • The properties management.metrics.export. are deprecated; the replacement is management..metrics.export.
  • The push setting of management.prometheus.metrics.export.pushgateway.shutdown-operation in favor of post.
  • Also, @AutoConfigureMetrics has been deprecated in favor of @AutoConfigureObservability. Furthermore, as Spring Boot 3 requires Spring Framework 6, it is essential to be familiar with the new features and improvements introduced in this latest version of the Spring Framework.

JDK 17+ and Jakarta EE 9+ Baseline

  • The entire framework codebase is based on Java 17 source code level now.
  • Migration from javax to jakarta namespace for Servlet, JPA, etc.
  • Runtime compatibility with Jakarta EE 9 as well as Jakarta EE 10 APIs.
  • Compatible with the latest web servers: Tomcat 10.1, Jetty 11, Undertow 2.3.
  • Early compatibility with virtual threads (in preview as of JDK 19).

General Core Revision

  • Upgrade to ASM 9.4 and Kotlin 1.7.
  • Complete CGLIB fork with support for capturing CGLIB-generated classes.
  • Comprehensive foundation for Ahead-Of-Time transformations.
  • First-class support for GraalVM native images (see related Spring Boot 3 blog post).

Core Container

  • Basic bean property determination without java.beans.Introspector by default.
  • AOT processing support in GenericApplicationContext (refreshForAotProcessing).
  • Bean definition transformation based on pre-resolved constructors and factory methods.
  • Support for early proxy class determination for AOP proxies and configuration classes.
  • PathMatchingResourcePatternResolver uses NIO and module path APIs for scanning, enabling support for classpath scanning within a GraalVM native image and within the Java module path, respectively.
  • DefaultFormattingConversionService supports ISO-based default java.time type parsing.

Data Access and Transactions

  • Support for predetermining JPA-managed types (for inclusion in AOT processing).
  • JPA support for Hibernate ORM 6.1 (retaining compatibility with Hibernate ORM 5.6).
  • Upgrade to R2DBC 1.0 (including R2DBC transaction definitions).
  • Aligned data access exception translation between JDBC, R2DBC, JPA, and Hibernate.
  • Removal of JCA CCI support.

Spring Messaging

  • RSocket interface client based on @RSocketExchange service interfaces.
  • Early support for Reactor Netty 2 based on Netty 5 alpha.
  • Support for Jakarta WebSocket 2.1 and its standard WebSocket protocol upgrade mechanism.

General Web Revision

  • HTTP interface client based on @HttpExchange service interfaces.
  • Support for RFC 7807 problem details.
  • Unified HTTP status code handling.
  • Support for Jackson 2.14.
  • Alignment with Servlet 6.0 (while retaining runtime compatibility with Servlet 5.0).

Spring MVC

  • PathPatternParser is used by default (with the ability to opt into PathMatcher).
  • Removal of outdated Tiles and FreeMarker JSP support.

Spring WebFlux

  • New PartEvent API to stream multipart form uploads (both on client and server).
  • New ResponseEntityExceptionHandler to customize WebFlux exceptions and render RFC 7807 error responses.
  • Flux return values for non-streaming media types (no longer collected to List before written).
  • Early support for Reactor Netty 2 based on Netty 5 alpha.
  • JDK HttpClient integrated with WebClient.

Observability

Direct Observability instrumentation with Micrometer Observation in several parts of the Spring Framework. The spring-web module now requires io.micrometer:micrometer-observation:1.10+ as a compile dependency.

  • RestTemplate and WebClient are instrumented to produce HTTP client request observations.
  • Spring MVC can be instrumented for HTTP server observations using the new org.springframework.web.filter.ServerHttpObservationFilter.
  • Spring WebFlux can be instrumented for HTTP server observations using the new org.springframework.web.filter.reactive.ServerHttpObservationFilter.
  • Integration with Micrometer Context Propagation for Flux and Mono return values from controller methods.

Testing

  • Support for testing AOT-processed application contexts on the JVM or within a GraalVM native image.
  • Integration with HtmlUnit 2.64+ request parameter handling.
  • In addition, Servlet mocks (MockHttpServletRequest, MockHttpSession) are now based on Servlet API 6.0.

How do you Upgrade to the Latest Version?
For those using a version earlier than 2.7.X and planning to migrate, it’s best to upgrade to the 2.7.x version first. This will ensure that you have the latest and most current component for building your application and will help avoid any potential compatibility issues that could arise from directly migrating to the latest version. Additionally, you can refer to the detailed migration guide for more information.

What are the minimum System requirements for running Spring Boot 3?
However, it now requires a minimum JDK 17, Graal 22.3 or later, and Native Build Tools Plugin 0.9.17. Therefore, to avail yourself of the latest features offered by Spring, you must first upgrade your JDK to version 17 or above.

But if you already have JDK 17 or above, you’re all set to use Spring Boot 3.

What is the latest Spring Boot version?
While the current stable version is SB 3, you can also have a look at the preview version here.

What are the important considerations to keep in mind before upgrading to Spring Boot 3?
If you’re planning to migrate from Spring Boot 2 to Spring Boot 3, there are a few things to keep in mind.

First, you need to update to Spring 2.7.x before upgrading to version 3.0. This will ensure that you have the latest components and avoid potential compatibility issues.

Another important thing to note is that Spring 3.0 requires Spring Security 6.0. However, it’s you need to first upgrade to Security 5.8 before migrating to 6.0. You can find a detailed migration guide to help you through the process.

Additionally, it’s worth noting Spring Boot 3.0 doesn’t support Java 8. Therefore, the minimum requirement is now Java 17, so you’ll need to upgrade your JDK accordingly.

Finally, since Spring 3 works on Spring 6, you’ll also need to update the Spring framework. Here are some instructions for upgrading to Spring version 6.0.

By following these steps, you should be able to migrate from Spring Boot 2 to Spring Boot 3 successfully.

Conclusion
We hope this article has provided you with enough information to decide whether you should upgrade to the latest version of Spring Boot or wait. To keep up-to-date with the latest advancements in Java web development, make sure to continue reading our blogs for updates and guides on recent developments in the field.

If you are looking to hire a Spring developer. In that case, it is essential to choose a provider offering seasoned professionals with extensive knowledge of the Spring framework and its related technologies.

To this end, at Brilworks, we provide Java application development services with a Spring developer on a full-time, contractual, or dedicated basis.
Source: https://www.brilworks.com/blog/whats-new-in-spring-boot-3-for-java-developers-in-2023/

Top comments (0)