Zademy

Spring Boot 4 and Spring Framework 7: The New Era of Java for Fast and Secure Microservices

Java
SpringBoot; Java
words words

I have a small service of my own that's been running Spring Boot 3 for a couple of years. Nothing glamorous: an API that pulls data from two vendors, stores it in Postgres, serves JSON. The kind of boring service you end up maintaining on some random Sunday.

Spring Framework 7.0 shipped on November 13. Spring Boot 4.0 followed on the 20th. On Friday the 21st, with my morning coffee, I opened a migration branch.

Not because the service urgently needed it. I wanted an honest answer to one question: how much of this release is real change, and how much is release-notes catalog? Two days in, here's what I have.

What OpenRewrite fixed and what was left to me

The first thing I ran was the community recipe org.openrewrite.java.spring.boot4.UpgradeSpringBoot_4_0. Worth stressing the community part: the Spring team doesn't maintain it, and it shows at the edges.

In one afternoon it had my build compiling again. It bumped dependencies, moved me to Jackson 3 (now the default, with Jackson 2 as a deprecated bridge that turns itself off: autodetection is disabled in 7.1 and gone in 7.2), and renamed a handful of yaml properties.

What it didn't fix was the interesting part. Undertow is no longer supported, so if that was your container, you're moving to Tomcat or Jetty. The starters got modularized and spring-boot-starter-web now answers as spring-boot-starter-webmvc; for me it was just a rename, but projects with custom starters will want to sit down and review. And TestRestTemplate ships separately now: it needs its own test dependency, though for new code there's RestTestClient, which types better while it's at it.

A green compile is not green-works. That part is still mine.

The 3 AM NPE

A while ago one of my vendors changed their API without warning, and a field that never once came back empty in development started arriving null in production. The service went down at 3 AM. An alert woke me up. Since then I distrust any API that doesn't declare its nulls.

So of everything Framework 7 brings, what interests me most is JSpecify: a standard put together by Google, JetBrains and others, which Spring adopted across the whole portfolio. IntelliJ and Eclipse already understand it. The cheapest way to adopt it in your own code is a package-info.java:

// src/main/java/com/zademy/service/package-info.java
@org.jspecify.annotations.NullMarked
package com.zademy.service;

With that, the whole package is non-null by default. Whatever can be missing gets marked @Nullable, and the IDE warns you while you type, not when it blows up in production with the pager going off. That early morning would have cost me less with this. Half the migration is justified by this change alone.

Declarative HTTP clients

The Framework 7 reference documentation already marks RestTemplate as deprecated. The @Deprecated annotation lands in 7.1. So nothing explodes today, but the path is written, and it's worth starting to walk it.

Its natural replacement, for me, is declarative clients with @HttpExchange. This used to require OpenFeign and its dependencies; now it lives in the framework:

@HttpExchange("/api/products")
public interface ProductClient {

    @GetExchange("/{id}")
    Product getProduct(@PathVariable("id") String id);

    @GetExchange
    List<Product> listProducts();

    @PostExchange
    Product createProduct(@RequestBody Product product);
}

You define what to call, not how. In tests it's trivial to fake because it's an interface. And if one day I need the reactive variant, clientType in @ImportHttpServices switches between RestClient and WebClient without touching the interface.

What already existed and what's actually new

Here comes my skeptical side. Several things celebrated as version 4 novelties aren't. JdbcClient, which is a joy to use, has existed since Framework 6.1. @Observed already came with Boot 3. And Micrometer is at 1.16 with Tracing 1.6, not some supposed 2.0 I kept reading elsewhere; the genuinely new bit there is the official OpenTelemetry starter.

What is actually new: native resilience in spring-context, with @Retryable, @ConcurrencyLimit and @EnableResilientMethods and no external dependencies; and API versioning finally going declarative, with the version attribute on @RequestMapping and spring.mvc.apiversion.* to pick the strategy. Both earned their spot on my branch.

On requirements: Java 17 floor, supported up to Java 25 (the recommended LTS), Kotlin 2.2, GraalVM 25, and full Jakarta EE 11 with Servlet 6.1, JPA 3.2 and Bean Validation 3.1. On performance, they promise faster startups thanks to autoconfiguration split into modules. I didn't run my own benchmark and other people's exhaust me, so that debt stays mine: measure it on the real service before repeating the promise.

The certificate near-miss

Another scare that stuck with me was a vendor certificate that expired on a Saturday. I found out because a user wrote in, not because anything alerted.

On the branch I set up the Actuator's certificate check: when one is about to expire, the health endpoint reports it before it becomes an incident. I didn't migrate for this, but of the things I configured these days, it's the one that gave me the most peace of mind. A near-miss teaches more than a changelog.

Verdict, for now

New projects: yes, without hesitation. Starting on the foundation for the next few years makes sense, and the rough edges of a .0 get smoothed out. I wrote this note days after GA and I'm deliberately not citing patch versions: by the time you read it, the 4.0.x line will have moved on.

Live projects: don't migrate out of inertia. Wait for a real trigger, like needing Jackson 3, versioned APIs, or shedding resilience dependencies. If none of that is pressing, Boot 3 doesn't fall over tomorrow.

My branch is half done: it compiles, most tests pass, and I still have integration tests plus a one-by-one review of property changes against the release notes. It wasn't an afternoon, and anyone who says otherwise didn't do it. But the service that comes out of that branch will be easier to maintain. For now, that's enough for me.