Native-Complied Java Microservices
In this chapter, we will learn how to compile the Java source code in our microservices into binary executable files, known as Native Images. A Native Image starts up significantly faster compared to using a Java VM and is also expected to consume less memory. We will be introduced to the Spring AOT engine introduced in Spring Framework 6 and the GraalVM project and its Native Image compiler, learning how to use them.
We will cover the following topics:
- When to natively compile Java source code
- Introducing the GraalVM project and Spring’s AOT engine
- Handling problems with native compilation
- Testing and compiling Native Images
- Testing with Docker Compose
- Testing with Kubernetes
Even though Spring Framework 6 and Spring Boot 3 come with General Availability (GA) support for building native executables of Spring Boot applications, it must be considered as being in an early stage. At...