Skip to content

Add native image guide: build, run, and configure the executable - #11

Merged
andreasarf merged 1 commit into
mainfrom
claude/practical-dirac-t5uv58
Oct 31, 2026
Merged

andreasarf merged 1 commit into
mainfrom
claude/practical-dirac-t5uv58

Conversation

@andreasarf

Copy link
Copy Markdown
Owner

Summary

Adds docs/native-image.md, linked from the README's native image section. It covers:

  • Prerequisites. GraalVM for JDK 25, gcc/zlib, memory, and the same-OS/architecture limitation.
  • Building. ./mvnw -Pnative -DskipTests native:compile, what happens and what it produces, and build memory tuning (-J-Xmx, --parallelism, -Ob).
  • Running. ./target/resourceapi: no JVM needed, graceful shutdown.
  • Runtime configuration. Command-line arguments, environment variables, a config/application.properties, and -Xmx.
  • Build-time configuration. Settings that choose which beans exist (springdoc on/off, profiles, virtual threads, HTTP client factory, tracing on/off) are frozen by AOT and ignored at runtime. The guide shows how to set them with -Dspring-boot.aot.jvmArguments=....
  • Troubleshooting. Missing reflection or resources, out-of-memory builds, glibc mismatches.

Verified against the native build of main

  • Runtime. --server.port=9090, SERVER_PORT=9091, ./config/application.properties (port 9092) and -Xmx64m all work.
  • Ignored at runtime. --springdoc.api-docs.enabled=false --springdoc.swagger-ui.enabled=false has no effect in the native executable (both still answer 200), while the same flags give 404 on java -jar.
  • Build time. Passing those flags through -Dspring-boot.aot.jvmArguments removes the springdoc beans from the AOT output (generated sources mentioning springdoc go from 11 to 2). I checked the AOT step only, not a full native build with them.
  • Not tested here. The other listed build-time properties follow from the same rule (they are bean conditions) but weren't each tried individually.

Generated by Claude Code

docs/native-image.md covers prerequisites, building, build memory tuning,
running the executable, configuring it at runtime (arguments, environment,
config files, -Xmx), settings that AOT fixes at build time and how to set
them (spring-boot.aot.jvmArguments), and troubleshooting. Linked from the
README.

Checked against the native build of main: --server.port, SERVER_PORT,
./config/application.properties and -Xmx work at runtime;
--springdoc.api-docs.enabled=false is ignored at runtime (it works on the
JVM), and passing it via spring-boot.aot.jvmArguments removes the springdoc
beans from the AOT output.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_012MLyPXGHeCc1fvTeB8JnT2
@andreasarf
andreasarf merged commit d1d1bb0 into main Oct 31, 2026
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants