Boot 3 — Jakarta, Virtual Threads & Native

Overview

Spring Boot 3 = Java 17+, jakarta.* namespace, and the foundation for virtual threads (Java 21) and GraalVM native images.

Official: Boot 3 Migration Guide, Virtual Threads, Native Images.


Table of contents

  1. javaxjakarta
  2. Spring Framework 6 baseline
  3. Virtual threads
  4. Native images & AOT
  5. Interview questions
  6. Summary

1. javaxjakarta

Boot 3 uses Jakarta EE 9+ package names:

Before After
javax.persistence.* jakarta.persistence.*
javax.validation.* jakarta.validation.*
javax.servlet.* jakarta.servlet.*
javax.annotation.PostConstruct jakarta.annotation.PostConstruct

Migration is mechanical but compulsory — Hibernate 6, Servlet 6, etc. all require the new packages.


2. Spring Framework 6 baseline

Useful additions you should know by name:

  • ProblemDetail — RFC 7807 errors in MVC.
  • @HttpExchange — declarative HTTP clients (Feign-style interfaces).
  • Observation API — unified metrics + tracing (see chapter 08).
  • Spring Security 6SecurityFilterChain only; WebSecurityConfigurerAdapter removed.

3. Virtual threads

spring:
  threads:
    virtual:
      enabled: true

With Java 21+ on the classpath, Tomcat handles each request on a virtual thread — so blocking I/O (JDBC, HTTP) scales like reactive without rewriting your code.

Caveats:

  • Pinning: a virtual thread holding a synchronized monitor while doing blocking I/O pins to its carrier thread, defeating the purpose. Prefer ReentrantLock.
  • It’s not magic — measure before claiming huge wins.

4. Native images & AOT

spring-boot-maven-plugin has a native goal that runs AOT processing to produce a GraalVM native binary.

Pros Cons
Startup in milliseconds Builds take minutes
Lower memory (RSS) Reflection / dynamic class loading needs config
Great for serverless / scale-to-zero Some libraries unsupported

Don’t go native by default. Measure cold-start pain first.


5. Interview questions

Q: Biggest breaking change from Boot 2 to Boot 3? A: The jakarta.* namespace and Java 17 baseline, plus Spring Security 6 dropping WebSecurityConfigurerAdapter.

Q: What are virtual threads useful for? A: Massive concurrency on blocking I/O workloads with normal-looking code. One property turns them on for Tomcat request handling.

Q: When do virtual threads pin? A: Inside a synchronized block holding a monitor across a blocking call. Switch to ReentrantLock to avoid it.

Q: What is Spring AOT? A: Ahead-of-time processing that generates reflection/proxy metadata so the app can be compiled to a GraalVM native binary.


6. Summary

Topic One line
Boot 3 jakarta.* + Java 17+
Virtual threads One flag; watch for synchronized pinning
Native Fast startup, slow build, reflection care

Next steps


Happy Learning

Next: Production Readiness & Deployment