Make sure that you are using GraalVM 22.3.0 or better and the equivalent version of native-image.
Use Spring Initializr to get started.
Links to configurations used in this example:
A folder for each of the build engines
Each folder contains:
- generated skeleton application (vanilla.zip)
- screenshot of the configuration used
Contains a simple controller for the sample app Hello.java (404 is not a great respoonse).
Hello.java
has been added to the src tree under each of the builds.
Contains unzipped builds of the vanilla
application for maven
and gradle
in respectively named folders:
Each of these contains the 'vanilla' app and the files for the appropriate build engine.
- from the command line,
cd
to the vanilla application folder - to build and run the application in one go
./gradlew bootRun
- to build the jar
./gradlew assemble
- to run the jar
java -jar build/libs/vanilla-0.0.1-SNAPSHOT.jar
- to compile to a native image
./gradlew nativeCompile
- to run the executable
./build/native/nativeCompile/vanilla
Make sure that $JAVA_HOME
has been to point to the GraalVM
installation
- from the command line,
cd
to the vanilla application folder - to build and run the application in one go
./mvnw spring-boot:run
- to build the jar
./mvnw package
- to run the jar
java -jar target/vanilla-0.0.1-SNAPSHOT.jar
- to compile to a native image
./mvnw -Pnative native:compile
- to run the executable
./target/vanilla