How Spring Native Beta Enables Ultra‑Fast, Low‑Resource Java Apps with GraalVM

Spring Native beta lets developers compile Spring Boot applications into GraalVM native images, delivering sub‑100 ms startup, peak performance and reduced resource usage, while providing Maven/Gradle plugins, AOT conversion, and seamless integration with start.spring.io for both Java and Kotlin projects.

Java High-Performance Architecture
Java High-Performance Architecture
Java High-Performance Architecture
How Spring Native Beta Enables Ultra‑Fast, Low‑Resource Java Apps with GraalVM

Spring Native Beta Release

The Spring team recently announced the Spring Native beta, which enables Spring applications to be compiled into GraalVM native images. Maven and Gradle plugins, along with optimization annotations, support this native execution mode.

Benefits of Native Spring Apps

Native Spring executables run as standalone binaries without a JVM, offering near‑instant startup (typically under 100 ms), peak performance, and lower resource consumption. The trade‑off is longer build times and fewer runtime optimizations.

How to Build a Native Image

Running mvn spring-boot:build-image or gradle bootBuildImage produces an optimized container image that contains a minimal OS layer and a native executable with only the required JDK, Spring, and application dependencies.

The resulting container can be as small as 50 MB, bundling Spring Boot, Spring MVC, Jackson, Tomcat, the JDK, and the application itself.

Typical Use Cases

Serverless applications using Spring Cloud Function

Cost‑effective, sustainable hosting of Spring microservices

Tight integration with Kubernetes platforms such as VMware Tanzu

Creating minimal container images for Spring services

Supported Scope

Spring Native has moved from alpha to beta, expanding its supported feature set. While still experimental, the beta indicates native support for a subset of the Spring ecosystem. Supported Spring Boot versions are updated with each patch release (e.g., Spring Native 0.9.0 supports Spring Boot 2.4.3, 0.9.1 supports 2.4.4).

Start.spring.io Integration

Stéphane Nicoll added Spring Native support to start.spring.io , making it the easiest way to explore native Spring applications.

Ahead‑of‑Time (AOT) Conversion

Spring Native introduces Maven and Gradle plugins for AOT conversion, generating GraalVM native configuration (reflection, resources, proxies) via a sophisticated inference engine. When automatic inference is insufficient, developers can use native hint annotations such as @NativeHint and @TypeHint to provide type and resource hints.

@NativeHint(
    trigger = Driver.class,
    options = "--enable-all-security-services",
    types = @TypeHint(types = {
        FailoverConnectionUrl.class,
        FailoverDnsSrvConnectionUrl.class,
        // ...
    }),
    resources = {
        @ResourceHint(patterns = "com/mysql/cj/TlsSettings.properties"),
        @ResourceHint(patterns = "com/mysql.cj.LocalizedErrorMessages", isBundle = true)
    })
public class MySqlHints implements NativeConfiguration {}

Developers can also place native hints directly on @Configuration or @SpringBootApplication classes, for example to configure JSON serialization for a Book class used with RestTemplate or WebClient.

@TypeHint(types = Book.class)
@SpringBootApplication
public class WebClientApplication {
    // ...
}

Conclusion

Spring’s native strategy has two pillars: adjusting the Spring infrastructure to be native‑friendly without breaking existing applications, and collaborating with the GraalVM team to improve compatibility and resource usage. AOT‑generated code runs on both the JVM (for fast feedback) and as a native image, offering performance gains even for non‑native deployments.

Original Source

Signed-in readers can open the original source through BestHub's protected redirect.

Sign in to view source
Republication Notice

This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactadmin@besthub.devand we will review it promptly.

JavanativespringgraalvmAoT
Java High-Performance Architecture
Written by

Java High-Performance Architecture

Sharing Java development articles and resources, including SSM architecture and the Spring ecosystem (Spring Boot, Spring Cloud, MyBatis, Dubbo, Docker), Zookeeper, Redis, architecture design, microservices, message queues, Git, etc.

0 followers
Reader feedback

How this landed with the community

Sign in to like

Rate this article

Was this worth your time?

Sign in to rate
Discussion

0 Comments

Thoughtful readers leave field notes, pushback, and hard-won operational detail here.