Spring Boot 3.0 is now available and includes more than 5,700 code commits from 151 developers over 12 months. This is the first major revision of Spring Boot since the release of 2.0 4.5 years ago.
It is also the first Spring Boot GA release to support Spring Framework 6.0 and GraalVM, and the first Java 17-based version of Spring Boot, benchmarked against Jakarta EE 9 and supporting Jakarta EE 10. It also supports AOT and Native Image with GraalVM.
If you want to try Spring Boot 3.0, you may want to refer to this upgrade guide.
Upgrading the JDK
First upgrade your JDK to JDK17, or if you want to use Native Image features, use GraalVM 22.3 or higher and Native Build Tools Plugin 0.9.17 or higher.
It is not recommended to upgrade directly from a version lower than Spring Boot 2.7 to Spring Boot 3.0, otherwise too many new features and API changes will require you to change a lot of configurations and the upgrade path will be too steep. It is recommended to upgrade to 2.4, 2.6, 2.7 and finally to 3.0 in stages via minor version numbers.
The version requirements for dependent components under Spring Boot 3.0 vary, for example, the Spring Boot Kafka Starter may have requirements for Kafka that require you to fully evaluate. the Spring Cloud system should be upgraded after the release of the corresponding Spring Boot 3.0 system.
Upgrading to Spring Boot 3
Once the above is ready, you can start trying to upgrade to Spring Boot 3.0.
Configuration Properties Compatibility
In Spring Boot 3.0, some configuration properties have been renamed/removed and developers need to update their
application.yml accordingly. To help you do this, Spring Boot 3.0 provides a
spring-boot-properties-migrator module. Once added to your project as a dependency, it will not only analyze your application’s environment and print diagnostics at startup, but will also temporarily migrate properties for you at runtime. Add the following to
pom.xml to help you upgrade your compatibility configuration properties.
After completing the migration, be sure to remove the
Since Java EE has been changed to Jakarta EE, the package names starting with
javax need to be changed to
jakarta accordingly. It is recommended to use the built-in function provided by Intellij IDEA 2021.2 to handle this in bulk.
Of course you can also change the package name manually.
Key Changes for the Upgrade
Spring Boot 3.0 has some key changes that will be relevant to most applications. So developers should read these changes carefully.
Image Banners are no longer supported
Now Spring Boot 3.0 Custom Banner only supports text types (
banner.txt) and no longer supports image types.
Log Date Format Change
The default format of the date and time portions of Logback and Log4j2 log messages has been changed to conform to the ISO-8601 standard. The new default format
T to separate the date and time instead of the space character and adds a time zone offset at the end. The
LOG_DATEFORMAT_PATTERN environment variable or the
logging.pattern.dateformat property can be used to restore the previous default value of
The ConfigurationProperties class annotation
@ConfigurationProperties is no longer required by default to mark constructions with
@ConstructorBinding, and you should remove it from the configuration class unless the configuration class has multiple constructors to explicitly configure the property binding.
JSON parsing is not consistent with other parser implementations. If you are using
YamlJsonParser directly, please migrate to another
Automatic Configuration File Changes
Spring Boot 2.7 introduced a new file.
This is used to register autoconfigurations while maintaining backward compatibility with registration in
spring.factories, which has been removed with the release of Spring Boot 3.0 and can only be registered via the
Web Application Changes
The path matching rules for Spring MVC and Spring Webflux have now been adjusted so that by default the trailing slash
/ will have a different matching mechanism than before.
- Before 3.0
/foo/baris equivalent to
- After 3.0
deprecated configuration server.max-http-header-size
server.max-http-header-size has been deprecated and is now replaced by
server.max-http-request-header-size and this property can now only be used to configure the size of request headers and no longer limits the response header size of certain web containers. Customize
WebServerFactoryCustomizer to achieve this.
Updated Phases for Graceful Shutdown
Graceful shutdown is implemented by
SmartLifecycle and starts at the
SmartLifecycle.DEFAULT_PHASE - 2048 phase and the web server is stopped at the
SmartLifecycle.DEFAULT_PHASE - 1024 phase. Any SmartLifecycle implementations that participate in graceful shutdown should be updated accordingly.
Since Jetty does not currently support Servlet 6.0, developers using Jetty need to reduce the version of Jakarta Servlet to 5.0.
Data access related changes
spring.data prefix has been reserved for the Spring Data project and if you are using a subproject of the Spring Data project, the relevant configuration properties in
application.yaml will need to be changed in response. For example
spring.redis now needs to be changed to
Data access related components are now using a relatively new version of.
- Flyway updated to 9.0
- Hibernate updated to 6.1
- R2DBC updated to 1.0
In addition, the automatic configuration of Flapdoodle embedded MongoDB has been removed and developers need to import it themselves if needed.
Elasticsearch’s Rest client uses a new API implementation, the old autoconfiguration and Spring Data Elasticsearch’s old client API has been removed.
Related changes will be made and shared later when they are organized.
Observability, metric tracking, Maven, and Gradle have also been changed to varying degrees, so check out the official Spring-Boot-3.0-Migration-Guide if you need to.