Spring Boot thin launcher

Spring Boot thin launcher

Overview

The Spring Boot Thin Launcher enables “thin JAR” packaging for Spring Boot applications. A thin JAR contains your application code plus metadata describing its dependencies; at runtime, the launcher resolves those dependencies from a Maven repository and then starts the application.

What gets packaged

When you build with the thin launcher/layout, the resulting archive typically contains:

  • Your application classes and resources.
  • A dependency descriptor (pom.xml and/or thin.properties).
  • A bootstrap main class, ThinJarWrapper, which is the JAR entry point.

Maven configuration (spring-boot-maven-plugin)

To build a thin JAR with Maven, configure the Spring Boot Maven plugin to use the custom “thin” layout by adding the spring-boot-thin-layout dependency:

<plugin>
  <groupId>org.springframework.boot</groupId>
  <artifactId>spring-boot-maven-plugin</artifactId>
  <dependencies>
    <!-- The following enables the "thin jar" deployment option. -->
    <dependency>
      <groupId>org.springframework.boot.experimental</groupId>
      <artifactId>spring-boot-thin-layout</artifactId>
      <version>@spring-boot-thin-layout.version@</version>
    </dependency>
  </dependencies>
</plugin>

Runtime behavior

When you run the thin JAR:

  1. The JVM starts ThinJarWrapper (the JAR’s main class).
  2. ThinJarWrapper locates the thin launcher implementation.
  3. The launcher reads dependency metadata from pom.xml (if present) and thin.properties.
  4. Dependencies (including transitive dependencies) are resolved from Maven repositories as needed.
  5. A new class loader is created with the resolved artifacts on its classpath.
  6. The application’s own main method is invoked using that class loader.