When moving a Spring Boot application from JVM deployment to GraalVM Native Image, separate two questions: which versions Spring Boot officially supports, and whether this project works under AOT and closed-world constraints. Native Image analyzes code at build time and produces an executable for a particular target platform. Dynamic use of reflection, resources, serialization, and proxies needs discoverable hints or explicit configuration. A supported version combination does not guarantee every dependency is compatible or that the app will use less memory or start faster.
As checked on 2026-11-29, the Spring Boot 4.0 migration guide requires Java 17 or later; native-image compilation requires GraalVM 25 or later. These are different requirements: Java 17+ is the application baseline, while the native compiler and build tools must meet Native Image requirements. With Buildpacks, also check the build JDK in the relevant documentation because the GraalVM version used by Buildpacks is tied to the Java version used for compilation. This guide uses Spring Boot 4.0 as its boundary; before upgrading, replace it with the specific maintenance version planned for the project and recheck its compatibility matrix.
Pin Versions and Select a Build Path
Record the Spring Boot patch, Spring Framework, JDK, build plugins, key dependencies, and deployment OS/CPU architecture before migration. Boot 4.0 is based on Spring Framework 7; check the official migration guide for modular starters, third-party starters, and API changes as well. Do not only upgrade the parent and immediately run a native build: first make the application pass regular JVM unit and integration tests on the target Boot version.
Then choose a build path. Spring Boot supports Native Build Tools with Maven or Gradle and supports native container images through Cloud Native Buildpacks. The JVM package and Native Image have different build processes and artifacts; Buildpacks also introduce builder, container runtime, and build-JDK considerations. Document repeatable local and CI steps so a developer's machine does not produce an artifact while CI uses an older GraalVM or a different architecture.
Check Dependencies for AOT and Dynamic Behavior
Native Image assumes a closed world and statically analyzes code reachable from the entry point at build time; the runtime classpath cannot be changed arbitrarily as it can in a JVM application. Spring AOT generates code and GraalVM metadata during the build. However, third-party dependencies that use dynamic behavior are not always discovered automatically.
Check these areas during migration:
- Reflection and dynamic proxies: Determine whether JSON serialization, ORM, plugin scanning, and proxy libraries provide native hints; add and test hints when needed.
- Resources and configuration: Confirm classpath resources, templates, certificates, scripts, and configuration files are included. Do not depend on adding to the classpath at runtime.
- Conditional beans: Bean definitions produced by AOT cannot change freely at runtime. Review designs that depend on profiles, conditional properties, or dynamic bean switching.
- Initialization and environment variables: Build-time initialization must not accidentally read production credentials or configuration. Keep settings that need runtime values in the runtime phase.
- Database and drivers: Verify metadata support and real connection behavior for the driver, pool, migration tool, and ORM with the chosen GraalVM version.
A “GraalVM supported” label is not acceptance. Inventory runtime dependencies and check versions, maintenance, and native-build guidance individually. Run integration tests for dynamic features that are not covered by hints; keep a JVM deployment path if required.
Compare Functionality and Cost with JVM Deployment
Build two artifacts from the same commit: the regular JVM version and the Native Image version. First confirm that behavior, error handling, configuration, health checks, database migrations, and shutdown are equivalent. Then measure startup phases, steady-state memory, CPU, throughput, build time, build resources, and image size under the project workload.
| Comparison area | Record for JVM deployment | Record for Native Image |
|---|---|---|
| Startup behavior | Same startup definition and first-ready time | Same readiness criterion and cold-start conditions |
| Memory and CPU | Runtime version, container limits, steady-state samples | Samples under the same workload and container limits |
| Build and delivery | Compile, package, and image process | AOT/native compile duration, build resources, target architecture |
| Compatibility and diagnosis | Runtime diagnostics and dependency upgrade path | Missing-hint failures, symbols, and reproduction path |
Spring describes faster startup and lower memory use as potential Native Image advantages. Whether they occur depends on the application, workload, container constraints, and build target; measure them in the same environment. For a service that runs steadily and has no startup or scaling constraint, extra native build and troubleshooting maintenance may not be worthwhile.
Migration and Acceptance Steps
- Upgrade to the planned Spring Boot 4.x maintenance version in JVM mode and resolve incompatible dependencies and APIs from its migration guide.
- Pin Java and GraalVM toolchain versions; check Native Build Tools or Buildpacks versions and build environment.
- Run AOT processing and build the native artifact. Classify failures as dependency hints, missing resources, or dynamic behavior, then add native configuration as needed.
- Test startup, health checks, authentication, database reads and writes, scheduled jobs, and shutdown on the target OS and architecture.
- Compare the native artifact with the JVM artifact from the same commit under one workload: startup, CPU, memory, image size, and build-maintenance cost. Switch the default deployment only if gains justify the team's added maintenance.
In the build environment, confirm the native compiler toolchain first, then run either the Maven or Gradle command matching your chosen build path:
# Confirm the local GraalVM native-image toolchain and target architecture
native-image --version
# Maven: build a local native executable or a Buildpacks native container image
./mvnw -Pnative native:compile
./mvnw -Pnative spring-boot:build-image
# Gradle: build a local native executable or a Buildpacks native container image
./gradlew nativeCompile
./gradlew bootBuildImage
Verification: native-image --version should report a GraalVM 25+ release and architecture matching the Spring Boot 4.x migration guide; local native compilation produces an executable under target/ (Maven) or build/native/nativeCompile/ (Gradle), while the Buildpacks task produces a local OCI image. If compilation or startup fails on reflection, proxies, or missing resources, add the required AOT/native hints, rebuild, and confirm the health endpoint on the target OS and architecture.
Keep the JVM artifact and rollback path for release. Validate first in a non-critical service or a small-traffic environment. Returning to the JVM artifact can shorten recovery when a failure involves native hints or a dependency; it does not replace fixing compatibility or adding tests.
Boundaries and Limitations
- Spring Boot 4.0's minimum Java runtime baseline and Native Image compiler-toolchain requirements differ. Recheck official system requirements and build documentation for another Boot version or Buildpacks path.
- GraalVM Native Image is target-platform-specific. Do not assume a binary compiled for one OS/CPU architecture can run directly in another environment.
- Runtime class loading, reflection, resource scanning, proxies, and runtime changes to bean structure can require hints, refactoring, or a different design.
- Official support defines a supported technical path; it does not guarantee a third-party library, project feature, build resource use, or performance gain.
Frequently Asked Questions
Is Java 25 required to run Spring Boot 4 in production?
No. The Spring Boot 4.0 migration guide lists Java 17 or later as the application baseline; native-image compilation separately requires GraalVM 25 or later. Java 17+ and GraalVM 25+ are separate baselines. Confirm the build JDK for your Buildpacks path and verify runtime, compiler, and builder versions separately before release.
Which dependencies are most likely to break a Native Image build?
Use the Spring Boot 4.0 and GraalVM 25 native-image notes to prioritize libraries that discover types or resources at runtime, including reflection, serialization, dynamic proxies, plugin scanning, and database mapping. Review native guidance for each dependency, inspect generated hints, and run integration tests. JVM startup alone does not prove native compatibility.
When is Native Image not a fit for a long-running service?
Avoid Native Image when startup is not a constraint, the service runs steadily, and maintaining GraalVM 25 adds more work than value. Spring documents potential characteristics, not guaranteed gains; application structure, workload, container limits, and target platform affect results. Compare artifacts from the same commit, include build time and troubleshooting cost, and measure the artifact before rollout.
What else should we check when using Buildpacks for a native image?
You need to check the builder, build JDK/GraalVM version, container runtime requirements, and target OS/architecture. For Boot 4, distinguish the Java 17+ runtime baseline from the GraalVM 25+ native compiler requirement. Buildpacks select a related GraalVM toolchain based on the build environment, so the application's Java target alone is not enough. Pin images and tools in CI, then verify the artifact in its target runtime.
Related Providers
- Spring Boot: check the support boundary for the existing Boot version and dependency set.
- Java: verify the JDK runtime baseline, compiler toolchain, and project version management.
- Quarkus: compare another Java native deployment path when the project evaluates alternatives, using the same workload and maintenance criteria.
References
- Spring Boot project page: official release support and documentation entry point.
- Spring Boot native image: official guidance on AOT processing, reflection hints, and native-image constraints.
- GraalVM Native Image: build flow and configuration reference for native executables.
- Spring Boot repository: source, release notes, and migration-guide index.
Community & Resources
- Backend Integration: continue with API design, runtime, and deployment-acceptance topics.
- To add Spring MVC request validation and API testing, see Spring Boot REST API Guide.
Original source: 16IDC Original ↗