Generate a spring boot 3 native app either in a docker image or an executable using graalVM.
You need a java graalVM distribution:
sdk install java 22.3.r17-nik
To create a docker image containing the native executable:
./gradlew bootBuildImage
Then, you can start the app with a container:
docker-compose -f docker-compose-spring-native.yaml up -d
Alternatively to create locally the native executable only run:
./gradlew clean nativeCompile
Then you can run the local app executable:
./build/native/nativeCompile/spring-native
Hit app endpoints with:
curl http://localhost:8080/api/books/
To run your existing tests in a native image, run the following goal:
./gradlew nativeTest
Start spring boot app using jar:
./gradlew bootRun
ref: