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.xmland/orthin.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:
- The JVM starts
ThinJarWrapper(the JAR’s main class). ThinJarWrapperlocates the thin launcher implementation.- The launcher reads dependency metadata from
pom.xml(if present) andthin.properties. - Dependencies (including transitive dependencies) are resolved from Maven repositories as needed.
- A new class loader is created with the resolved artifacts on its classpath.
- The application’s own
mainmethod is invoked using that class loader.