Spring / Spring Boot 4 Basics Interview Questions
What is the Java version baseline in Spring Boot 4 and what Java features does it unlock?
Spring Boot 4 maintains Java 17 as the minimum baseline while adding first-class support for Java 25. The decision to keep Java 17 as the minimum was deliberate -- as Spring Framework project lead Juergen Hoeller stated, "the current industry consensus is clearly around a Java 17 baseline."
| Java version | Support level | Notable features |
|---|---|---|
| Java 17 | Minimum required | Text blocks, records, sealed classes, pattern matching preview |
| Java 21 | Strongly recommended | Virtual threads (stable), structured concurrency (preview), sequenced collections |
| Java 25 | First-class, tested | AOT compilation improvements, GraalVM native optimisations, vector API incubator |
| Java 26 | Supported in Boot 4.1 | Structured concurrency (preview), further platform improvements |
# application.properties -- enable virtual threads (Java 21+) spring.threads.virtual.enabled=true # When enabled, Spring Boot optimises internal task executors # to use lightweight virtual threads instead of platform threads # Making blocking code perform like reactive code without complexity # GraalVM native image in Spring Boot 4 requires: # GraalVM native-image version 25 or later # Build native image: # ./mvnw -Pnative native:compile # ./gradlew nativeCompile
Virtual threads and Spring Boot 4: with spring.threads.virtual.enabled=true, the framework automatically switches internal Tomcat thread pools, Spring MVC request handling, and @Async executors to use Java virtual threads. This delivers near-reactive throughput for blocking I/O code without requiring reactive programming paradigms.
More Related questions...