Spring Boot 4 just released – everything you need to know

Spring Boot 4 just released - everything you need to know

Spring Boot 4 is here, bringing faster performance, improved security, and better tools for building modern applications. With features like Ahead-of-Time (AOT) compilation, null safety updates, and built-in resilience patterns, it simplifies development while enhancing reliability. Here’s what you need to know:

  • AOT Compilation: Startup times are now 50–70% faster, with reduced memory usage and better support for GraalVM native images.
  • Null Safety: New annotations like @NonNull and @Nullable help prevent runtime errors and improve code quality.
  • Production Tools: Integrated OpenTelemetry and Micrometer 2.x provide better observability, while resilience features like @Retryable ensure fault tolerance.
  • Breaking Changes: Requires Java 17+, adopts Jakarta EE 11, and removes older features like Undertow support and some test configurations.

Migrating from Spring Boot 3? Plan carefully by reviewing dependencies, testing thoroughly, and using tools like Spring Boot Migrator for a smoother transition. Whether you’re starting new projects or upgrading, Spring Boot 4 offers powerful tools for building efficient and scalable applications.

What’s New in Spring Boot 4

Spring Boot 4 brings notable updates designed to boost the performance of enterprise applications, particularly in cloud-native settings.

Performance Gains with AOT Compilation

One standout feature in Spring Boot 4 is Ahead-of-Time (AOT) compilation. With the introduction of Spring Data AOT, query generation is now handled during compile-time instead of runtime. This shift results in startup times that are 50–70% faster and reduces memory usage. As Dan Vega highlights, “Spring Data AOT dramatically improves startup time”.

Support for GraalVM native images has also been significantly improved. The spring-boot-aot-native plugin is now fully integrated into Spring Boot’s core tooling, making native image compilation a seamless process. This is a game-changer for microservices and cloud-native applications, where quicker cold starts and smaller container sizes contribute to lower operational costs and faster deployments.

Another advantage of AOT processing is its ability to catch errors during the build phase. Issues like query typos or misconfigurations that previously appeared at runtime are now flagged earlier, reducing the chance of runtime failures. Additionally, pre-compiled repository implementations and the ability to inspect generated code make debugging more straightforward.

Developer Experience Updates

Spring Boot 4 brings updates designed to streamline development and enhance code reliability. One of the standout features is its adoption of JSpecify, which strengthens null safety and helps reduce runtime errors.

Null Safety and Type Safety

Spring Boot 4 introduces annotations like @NonNull, @Nullable, and @NullMarked to define clear rules for handling null values. For example, marking a parameter with @NonNull ensures that it must always have a value, while @Nullable signals that a value might be absent and requires explicit handling. These annotations make code behaviour more predictable and safer.

Modern IDEs, such as IntelliJ IDEA 2025.3, now offer real-time warnings for potential null pointer issues. Additionally, applying @NullMarked at the package level (via package-info.java) sets a default non-null policy, reducing the need for repetitive annotations throughout the codebase.

The PropertiesConfigAdapter interfaces have also been updated to better handle nullability. To take advantage of these features, developers can include the JSpecify library (org.jspecify:jspecify:1.0.0) and apply package-level @NullMarked annotations. For those working with Kotlin, the Kotlin compiler natively supports JSpecify annotations, making Spring Boot 4 particularly appealing for projects that combine Java and Kotlin.

These updates not only minimise runtime errors but also cut down on debugging time, allowing teams to dedicate more energy to building new features. By introducing this robust null safety framework, Spring Boot 4 sets the stage for even more improvements in developer productivity.

Production Features for Reliability and Monitoring

When it comes to production applications, reliability and system visibility are non-negotiable. Spring Boot 4 addresses these priorities with its built-in resilience patterns and improved observability tools, which integrate effortlessly into your workflow.

Built-in Resilience Patterns

With the release of Spring Framework 7.0 and Spring Boot 4.0 in November 2025, resilience features are now baked directly into the framework. This means you can implement fault-tolerant patterns using familiar Spring annotations, without needing external libraries.

Take the @Retryable annotation, for instance. It lets you handle transient issues like network timeouts or temporary service outages by automatically retrying failed operations. Then there’s @ConcurrencyLimit, which helps manage concurrency by limiting resource use for external APIs – particularly useful when working with Virtual Threads.

To activate these features, simply include @EnableRetry in a @Configuration class. Once set up, these tools operate seamlessly in the background, allowing your core business logic to stay focused while gracefully managing potential failures.

And it doesn’t stop there. Alongside these resilience tools, Spring Boot 4 offers enhanced observability features to keep a close eye on your application’s health and performance.

Better Observability with OpenTelemetry

When something goes wrong in production, understanding what’s happening under the hood is critical. Spring Boot 4 makes this easier with its tighter integration with OpenTelemetry and an upgrade to Micrometer 2.x.

The new spring-boot-starter-opentelemetry module bundles everything you need to export metrics and traces using the OpenTelemetry Protocol (OTLP). The setup is straightforward – OpenTelemetry’s SDK is pre-configured, and the tracing property has been updated from management.tracing.enabled to management.tracing.export.enabled for clarity.

Micrometer 2.x works hand-in-hand with OpenTelemetry, tying together traces, logs, and metrics in cloud-native applications. This unified approach means you can pinpoint, for example, why an API is slow by correlating its response time with specific log entries and system metrics.

The @Observed annotation takes things a step further by simplifying method-level monitoring. Just add it to methods you want to track, and the framework will automatically generate timers, counters, and traces – no need for complex setups or manual instrumentation.

Spring Boot 4 also enhances Redis auto-configuration by enabling MicrometerTracing out of the box. This leverages the Observation API to provide both metrics and spans that OpenTelemetry can use, extending observability to your caching layer with zero additional effort.

Thanks to its modular design, the OpenTelemetry integration is packaged in a focused module, resulting in cleaner dependencies and quicker build times.

Getting started is easy. Add the spring-boot-starter-opentelemetry dependency to your project, use the @Observed annotation on key methods, and let the framework handle the telemetry data. This data will then be readily available for analysis on your observability platform.

These updates build on the groundwork laid in Spring Boot 3, with the move to Micrometer 2 and the dedicated OpenTelemetry starter marking a big leap forward. For production teams, this means better visibility into their systems, less time spent troubleshooting, and more reliable services overall.

How to Migrate from Spring Boot 3 to Spring Boot 4

We’ve since published a much deeper companion piece:  the complete 3.5 to 4 migration guide, with every error we could verify

Upgrading to Spring Boot 4 requires careful planning to ensure a smooth transition. With notable changes introduced in this version, it’s essential to address these updates systematically. Here’s a breakdown of the key changes and a step-by-step guide to help you navigate the migration process.

Breaking Changes and Deprecated Features

Spring Boot 4.0 comes with several breaking changes that you’ll need to address for your application to function correctly.

  • System requirements have increased: At a minimum, you’ll need Java 17, though Java 25 is recommended. For Kotlin users, version 2.2 or later is required, and GraalVM users must upgrade to version 25 or higher. The framework also now relies on Jakarta EE 11 and requires a Servlet 6.1 baseline.
  • Package structure updates: The framework has adopted a modular design, reorganising packages under org.springframework.boot.<module>. This means you’ll need to update imports across your codebase.
  • Removed features: Several features have been discontinued, including Undertow support, Pulsar Reactive, embedded executable uber jar launch scripts, and Spring Session support for Hazelcast and MongoDB. Integration support for Spock testing has also been removed, so you’ll need to explore alternatives.
  • Jackson 3 adoption: Jackson 3 is now the preferred version, with new group IDs and package names under tools.jackson. Any custom serialisation logic will need adjustments. A temporary spring-boot-jackson2 module is available to bridge the gap, but it’s not a long-term solution.
  • Testing changes: The @SpringBootTest annotation no longer includes MockMVC, WebClient, or TestRestTemplate by default. You’ll need to explicitly add @AutoConfigureMockMvc, @AutoConfigureWebTestClient, or @AutoConfigureTestRestTemplate annotations as needed. Additionally, it’s recommended to replace TestRestTemplate with the newer RestTestClient.
  • Starter POM updates: Starter POMs have been renamed and restructured. For example, spring-boot-starter-web is now spring-boot-starter-webmvc. Applications using starter POMs will generally have the correct dependencies, but testing infrastructure and technologies without dedicated starter POMs may require extra attention.

Before starting the upgrade, ensure you’re using the latest 3.5.x version. This allows you to work with the most recent dependencies and identify deprecated methods that won’t work in Spring Boot 4.0.

Planning Your Migration

To minimise risks, take a structured approach to the migration process. Here’s how to prepare and execute the upgrade effectively:

  • Review dependencies: Check how Spring Boot 4.0’s dependency changes impact your project, especially for dependencies not managed by Spring Boot, such as Spring Cloud. Confirm compatible versions before proceeding.
  • Leverage automation tools: Tools like Spring Boot Migrator (SBM) and OpenRewrite can automate much of the migration process. They offer “recipes” for common tasks, such as updating imports, dependencies, and APIs. OpenRewrite’s composite recipes are particularly helpful for large-scale migrations, handling updates for Java, Jakarta, Spring Framework, Jackson, and JUnit in one operation.
  • Update custom configurations: If you’ve created custom auto-configuration or starter modules, update your imports and dependencies accordingly. Review your pom.xml or build.gradle files to ensure you’re using the new, more focused starter modules and including the appropriate test starters in the test scope.
  • Use “Classic Starters” for gradual migration: For complex migrations, spring-boot-starter-classic and spring-boot-starter-test-classic can help get your application running on Spring Boot 4 while you gradually transition to the new modules. This approach provides breathing room but isn’t meant to be a permanent solution.
  • Test thoroughly: Implement comprehensive tests before and after the migration to ensure functionality and performance remain intact. Major version upgrades can introduce subtle behavioural changes that may only appear in specific scenarios.
  • Adopt a phased approach: Break the migration into smaller, manageable steps. Document and test rollback plans to ensure you can revert changes if needed. Monitor resource usage – such as RAM, CPU, and disk space – before and after deployment to catch unexpected issues.
  • Inspect dependencies: Use tools like Maven‘s dependency:tree to analyse your project’s dependencies. This helps identify conflicts or unexpected versions that might cause problems.

The modular design of Spring Boot 4 requires a more deliberate approach to selecting dependencies, but it also leads to cleaner builds and faster compile times. Take the time to determine which modules your application truly needs instead of relying on broad starter POMs.

If you’re working with a large codebase or multiple applications, consider starting with a smaller, less critical application. This pilot migration allows you to identify potential challenges and refine your process before tackling your primary systems.

Conclusion

Spring Boot 4 brings a host of improvements designed to meet modern development needs. Its modular architecture, faster AOT compilation, and lower resource consumption make it a game-changer for large-scale systems and cloud-native applications. By reducing build times, deployment sizes, and memory usage, it delivers practical benefits that streamline both development and operations.

Developers will appreciate the improved experience, with stronger type safety ensuring fewer errors and more reliable code. The inclusion of native OpenTelemetry integration and built-in resilience features simplifies production readiness, eliminating the need for extensive custom configurations. This allows teams to concentrate on crafting business logic instead of wrestling with infrastructure complexities.

For organisations looking to modernise, Spring Boot 4 offers a dependable platform for building scalable and maintainable applications. Its performance enhancements not only improve user satisfaction but also cut operational costs. By aligning with modern Java standards and cloud-native practices, it ensures your applications remain adaptable to future demands.

Addressing earlier migration challenges, the framework’s modular design promotes cleaner, more maintainable codebases. This makes it easier for teams to extend and adapt their systems as requirements evolve. Embracing these updates equips teams to work more efficiently and respond quickly to changing needs.

Whether you’re starting fresh or upgrading existing systems, Spring Boot 4 provides the tools and features to meet today’s enterprise demands while staying prepared for the challenges ahead. With thoughtful migration planning, organisations can unlock its full potential and reap the rewards of a modern, forward-thinking framework.

FAQs

What should I consider when upgrading from Spring Boot 3 to Spring Boot 4, and how can I make the process seamless?

When moving to Spring Boot 4, take some time to revisit and adjust your dependencies. Look into adding the starter modules for technologies that now come with built-in support, and make use of the updated test starters to simplify your testing process. If you’ve been using custom or manual configurations, consider swapping them out for the newer modular alternatives. Don’t forget to update any package names that may have changed.

To make the upgrade process seamless, test your application thoroughly after implementing these updates. It’s also worth going through the release notes to check for any breaking changes or features that have been phased out. With proper planning and testing, you’ll be set to take full advantage of the performance upgrades and tools that Spring Boot 4 offers.

What benefits does Ahead-of-Time (AOT) compilation in Spring Boot 4 offer, especially for cloud-native applications?

Ahead-of-Time (AOT) compilation in Spring Boot 4 brings a noticeable boost to application performance, particularly in cloud-native setups. By pre-compiling code during the build stage, it enables quicker startup times, lowers memory consumption, and improves runtime efficiency.

This approach proves especially useful for containerised and serverless deployments, where scaling swiftly and using resources wisely are top priorities. AOT compilation allows developers to create streamlined, responsive applications that align with the demands of modern software development.

What are the new null safety features in Spring Boot 4, and how do they help improve code reliability?

Spring Boot 4 brings JSpecify null safety into the spotlight, offering a way to make code more reliable while cutting down on runtime errors. With annotations like @Nullable and @NonNull, developers can clearly define whether a value is allowed to be null, adding transparency to the code’s intent.

What’s more, these annotations work seamlessly with the Kotlin compiler and IntelliJ IDEA. They provide compile-time warnings whenever nullability rules are breached, helping developers catch problems early. The result? Code that’s easier to maintain and far less prone to unexpected bugs.

David Brown founded Tucanoo Solutions in 2011 and has written software in a professional capacity for over 30 years, back to the Java/J2EE days of Sun Microsystems. He builds cloud and web applications for clients in legal tech, government and beyond, including several years consulting to the United Nations on customs and transport systems. He writes these tutorials himself, with the full code on GitHub.

Leave a Reply

Your email address will not be published. Required fields are marked *