Spring Ahead of Time

Spring AOT processing is part of the process to create a native binary from a Spring (Boot) application. This extension will help in adding a lot of hints which are needed for Axon Framework. Please note this extension can only be used with Spring Boot 3, as such it requires at least Java 17.

Besides the extension, it might be necessary to make more changes to successfully compile and run an application as a native image. For example, when a message isn't used in a handler. This is quite common when the application is split, and the application sending certain messages is not the same as the application handling the messages. In those cases these messages need to be added to the ImportRuntimeHints annotation. Otherwise, these messages can't be deserialized, leading to errors at runtime.

If something is not working or only works with additional hints, and it's Axon-specific, please let us know either at GitHub or Discuss.

Compiling to native

Before you set up this extension, it's important to read through the documentation from Spring itself. There are some known limitations that might require additional changes to the application. In addition, this extension needs to be added by adding the following dependency:


<dependency>
    <groupId>org.axonframework.extensions.spring-aot</groupId>
    <artifactId>axon-spring-aot</artifactId>
    <version>4.8.0</version>
</dependency>

This should be enough to have additional hints with ahead of time compilation to successfully build and run your Axon application.

Performance tips

It can be beneficial to move from JPA implementations to JDBC implementations. This likely decreases both the time it takes to compile the image and the time to start the image.

Last updated