-
Notifications
You must be signed in to change notification settings - Fork 40.9k
Spring Boot with GraalVM
-
Signed JARs (used for example in the Azure Java SDK) are not supported out of the box. See this comment on the spring-framework issue for the proposed workaround.
-
GraalVM with Truffle (Ruby,JavaScript) as a native image does not work with Spring applications because this disables inlining support.
-
Using beans defined as lambdas or instance suppliers with AOT/native is not yet supported (for example when using a functional router with WebFlux). You can track the related issue spring-framework#29555 where some workarounds are described.
-
Loading external resources using the
"jar"
protocol is not supported by default, as it’s not enabled by default. You can enable this in your build with the--enable-url-protocols=jar
option with the native build tools build plugin.
-
Mockito is not supported yet, see #32195. You can disable tests which rely on Mockito with
@DisabledInNativeImage
.
-
Paketo Buildpacks do not yet have official support for building images for ARM. Instructions for creating your own ARM-compatible builder are available. There are alternative builders available, too.
-
WebJars are not recommended with native images since the
webjars-locator-core
dependency involves unsupported resource scanning at runtime, and since WebJars dependencies lead to the inclusion of unneeded resources fromMETA-INF/resources/
. Consider alternative approaches like directly shipping the required frontend resources in the web application, potentially by leveraging build plugins like the gradle-node-plugin for Gradle or the frontend-maven-plugin for Maven (see related blog post).
HSQLDB is not supported in a native image. If you require an in-memory database, please use H2 instead.
Automatic detection of Java migrations are not supported in native image, see #33458
Gradle projects written in Kotlin will fail with a ClassCastException
when attempting to configure Hibernate’s bytecode enhancement. HHH-15707 is tracking the problem.
If org.glassfish.jaxb:jaxb-runtime
is used (for example, JPA / Hibernate depends on it), you’ll need to install the libfreetype
library on your Linux or MacOS system. That’s because a class inside JAXB depends on javax.imageio
, which will initialize the graphics subsystem.
Spring-WS does not support AOT and GraalVM Native at the moment.
Please see their dedicated document.
To use Spring Cloud Azure with GraalVM, you’ll need to add the spring-cloud-azure-native-reachability
dependency
tomcat-embed-programmatic
is an experimental Tomcat dependency designed to lower the memory footprint. Using it produces smaller native images.
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
<exclusions>
<exclusion>
<groupId>org.apache.tomcat.embed</groupId>
<artifactId>tomcat-embed-core</artifactId>
</exclusion>
<exclusion>
<groupId>org.apache.tomcat.embed</groupId>
<artifactId>tomcat-embed-websocket</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.apache.tomcat.experimental</groupId>
<artifactId>tomcat-embed-programmatic</artifactId>
<version>${tomcat.version}</version>
</dependency>
implementation('org.springframework.boot:spring-boot-starter-web') {
exclude group: 'org.apache.tomcat.embed', module: 'tomcat-embed-core'
exclude group: 'org.apache.tomcat.embed', module: 'tomcat-embed-websocket'
}
String tomcatVersion = dependencyManagement.importedProperties['tomcat.version']
implementation "org.apache.tomcat.experimental:tomcat-embed-programmatic:$tomcatVersion"