How Spring Native Beta Enables Fast, Low‑Memory Spring Apps with GraalVM
Spring Native beta introduces Maven and Gradle plugins that let Spring applications be compiled into GraalVM native images, delivering near‑instant startup, reduced memory usage, and container‑ready executables while outlining supported features, AOT transformation, and practical use cases for cloud‑native deployments.
Spring team announced the beta of Spring Native, allowing Spring applications to be compiled into GraalVM native images.
Spring Native provides Maven and Gradle plugins and annotations to optimize native configuration.
Native Spring apps run as standalone executables without a JVM, offering near‑instant startup (<100 ms), peak performance and lower memory usage, though build time and runtime optimizations are required.
Two simple commands generate an optimized container image containing a minimal OS layer and a native executable:
mvn spring-boot:build-image gradle bootBuildImageTypical use cases include serverless with Spring Cloud, cost‑effective hosting of micro‑services, Kubernetes platforms such as VMware Tanzu, and creating optimal container images.
While still experimental, the beta supports a subset of the Spring ecosystem; projects using supported dependencies can try it, and issues are reported as errors or requests.
Each Spring Boot 2.x patch releases a new Spring Native version (e.g., 0.9.0 for Boot 2.4.3, 0.9.1 for Boot 2.4.4).
1. Team Collaboration
Spring Native beta results from extensive collaboration across Spring projects (Framework, Boot, Data, Security, Cloud, Initializr) and the GraalVM team to improve compatibility and resource consumption.
2. Support Scope
While still experimental, the beta supports a subset of the Spring ecosystem; projects using supported dependencies can try it, and issues are reported as errors or requests.
Each Spring Boot 2.x patch releases a new Spring Native version (e.g., 0.9.0 for Boot 2.4.3, 0.9.1 for Boot 2.4.4).
3. start.spring.io Integration
Spring Native support is now integrated into start.spring.io, automatically adding the necessary dependencies and plugins to Maven or Gradle projects.
Generated HELP.md lists useful links and flags unsupported dependencies.
4. Ahead‑of‑Time (AOT) Transformation
Native images have a fixed classpath at build time; Spring AOT plugins generate GraalVM configuration (reflection, resources, proxies) based on annotations such as @NativeHint and @TypeHint.
@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 annotate their own @Configuration or @SpringBootApplication classes to generate native hints.
@TypeHint(types = Book.class) @SpringBootApplication public class WebClientApplication { /* ... */ }5. Conclusion
Spring’s native strategy has two pillars: making the Spring stack native‑friendly without massive changes, and collaborating with GraalVM to bridge the gap between JVM and native platforms.
Signed-in readers can open the original source through BestHub's protected redirect.
This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactand we will review it promptly.
Java Backend Technology
Focus on Java-related technologies: SSM, Spring ecosystem, microservices, MySQL, MyCat, clustering, distributed systems, middleware, Linux, networking, multithreading. Occasionally cover DevOps tools like Jenkins, Nexus, Docker, and ELK. Also share technical insights from time to time, committed to Java full-stack development!
How this landed with the community
Was this worth your time?
0 Comments
Thoughtful readers leave field notes, pushback, and hard-won operational detail here.
