Hilla uses Spring Boot 3 and supports native image compilation with GraalVM. By compiling your application into a native image, you can benefit from much faster startup times (milliseconds) and lower memory consumption compared to running the application on the JVM.
Before you begin, ensure you have a JDK with GraalVM support.
To check whether you have a JDK with GraalVM support, execute the
java -version command in your terminal.
If the output contains the following text, you have a JDK with GraalVM support installed:
To compile your Hilla application into a native image, follow these steps:
Compile your application using Maven by executing the following command in the project root directory:
mvn -Pproduction -Pnative native:compile
This command compiles your application with the production and native profiles enabled. The native profile instructs Maven to use the GraalVM native image compiler for the compilation process.
Run the application. The compilation creates the native image in the target directory. To run the application, execute the following command:
Your Hilla application is now running as a native image, benefiting from faster startup times and lower memory consumption.
For more information on native image compilation and instructions on creating Docker images using build packs, see the Spring Boot Reference Guide.