I have read about ahead of time compilation and that there is Micronaut, a Java framework to do so.
I just wanted to know if it's possible to do that in Spring Boot.
I have read about ahead of time compilation and that there is Micronaut, a Java framework to do so.
I just wanted to know if it's possible to do that in Spring Boot.
You can use Spring Native:
Spring Native provides support for compiling Spring applications to native executables using the GraalVM native-image compiler.
Spring Native is still beta, at version 0.9.2 as of Apr 20, 2021.
Just by using Java and Spring boot, I do not think so. Since the AOT compiled code will be platform dependent, it will contradict what we currently have with Java. Java achieves platform independency using java bytecode. With AOT, it will have bypass the step for generating java bytecodes and with the current java architecture in place, it is not possible. The red line on the diagram below shows what AOT compilation in Java with the current architecture will have to do.
However new techs are emerging, such as GraalVM. GraalVM will create a native image of the code, which means the code will be compiled to machine code directly (with GraalVM's compiler) and will be executed on the GraalVM platform. This provide the opportunity to have multiple languages executed at runtime. Like we can have an application whose codebase is in Java and Python. We have some limitations on these platforms for now, which makes them kinda experimental. But I won't be surprised to see AOT compiled java code in the future running on a different platform.