This repository provides a showcase of building a native image for a plain Spring Framework application.
Building a native image for a Spring Application requires the following:
-
Invoking AOT on the
ApplicationContext
. -
Compiling the generated code.
-
Copying bytecode and generated resources so that it is bundled properly.
Invoking AOT as an external process happens via an extension of org.springframework.context.aot.ContextAotProcessor
.
This repository provides such an extension that also perform the two other steps.
The exec-maven-plugin
can be used to invoke such process at the appropriate time.
In this example, the main "app" must have a method with the following signature:
private static GenericApplicationContext prepareApplicationContext() { ... }
To run the sample you need first to install GraalVM.
Make sure that native-image
is available in your path:
$ ./mvnw package -Pnative