Skip to content

Spring Boot with GraalVM

Moritz Halbritter edited this page Nov 22, 2022 · 52 revisions

Known GraalVM Native Image limitations

General

Testing

  • Mockito is not supported yet, see #32195

Building Container Images

Further GraalVM tweaking

Using tomcat-embed-programmatic

Motivation

tomcat-embed-programmatic is an experimental Tomcat dependency designed to lower the memory footprint. Using it produces smaller native images.

Maven

<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"
Clone this wiki locally