A Spring Boot fat jar is a self-contained executable archive; a layered jar is that same kind of archive with extra metadata that helps container builds reuse stable contents. Choose a plain executable jar for a straightforward deployment, or use layers when you build container images and want dependency changes to be separate from frequent application-code changes. Keep DevTools in development: Spring Boot excludes it from repackaged archives by default and warns against enabling it in production.
What is the difference between a fat jar and a layered jar?
In Spring Boot, “fat jar” usually means an executable archive containing your application and its dependencies. The Spring Boot plugin’s repackage goal creates this archive, which you can launch with java -jar. It is not necessarily an uber-jar with every dependency’s classes merged together: application classes and resources are under BOOT-INF/classes, while dependency jars are under BOOT-INF/lib. See the Spring Boot Maven Plugin documentation on executable archives.
As an Amazon Associate I earn from qualifying purchases.
A layered jar retains the executable-jar layout and adds a layers.idx index that identifies which content belongs to each layer. The index gives container tooling a way to separate relatively stable content from files likely to change. In the default arrangement, dependencies come before application content, so a code change need not invalidate every earlier image layer.
Default layer groups
- dependencies: dependency versions that are not SNAPSHOT versions.
- spring-boot-loader: Spring Boot’s archive loader.
- snapshot-dependencies: SNAPSHOT dependency versions.
- application: local module dependencies, application classes, and resources.
The plugin includes the layer index by default; it can also be disabled or customized. Current plugin documentation says layered archives include spring-boot-jarmode-tools to support operations such as extracting layers. Check the documentation for your project’s Spring Boot version before copying configuration, since plugin defaults and tools have evolved.
Which deployment pattern should you use?
| Approach | What goes into the image | Main advantage | Tradeoff | Good fit |
|---|---|---|---|---|
| One executable jar | A single jar, copied into the image and run with java -jar. |
Fewer packaging and runtime steps. | A changed jar can change the image layer containing it. | A simple container deployment or a non-container deployment. |
| Layered or exploded content | Libraries and application classes/resources are copied separately. | Stable dependency content can be cached independently of frequently changed application files. | More explicit image steps and classpath handling; extraction can change classpath order. | Container builds where application files change more often than dependencies and layer reuse is valuable. |
Spring’s Spring Boot with Docker guide demonstrates both patterns: copying one jar and starting it with java -jar, or copying extracted libraries and application files separately and starting with an explicit classpath. Container runtimes commonly cache image layers, so the latter can avoid rebuilding unchanged dependency layers. That is a workflow advantage, not a guarantee of faster builds, smaller images, or faster application startup in every setup.
One practical caveat with the exploded approach is classpath order. The Docker guide notes that extracting the jar can change that order. Well-behaved applications should not depend on it, but dependency-management problems may become visible when switching layouts. Test the actual image and application rather than assuming the layouts are interchangeable in every project.
Rank #2
How do you build an executable jar with Maven?
- Run Maven’s normal
packagephase so the project’s archive exists. - Let the Spring Boot Maven plugin’s
repackagegoal convert that archive into an executable one. Projects usingspring-boot-starter-parenthave the execution preconfigured; invokingrepackagealone does not create its input archive. - Run the resulting executable archive with
java -jar. Repackaging updates manifest entries such asMain-ClassandStart-Class.
By default, the original non-executable artifact is renamed with an .original suffix; classifier configuration can affect this behavior. The plugin documentation also says spring-boot-devtools and spring-boot-docker-compose are excluded by default, with properties available to control those exclusions. Consult the plugin packaging documentation for version-specific options.
What’s actually slowing this PC down?
Pick the symptom - the matching free tool is one click away.
Where does DevTools belong?
Spring Boot DevTools provides development-time features, including quick restarts and development-oriented settings such as disabling selected caches that can obscure source changes. Keep it out of the normal production artifact. The Spring Boot 3.0.x reference documents Maven setup with <optional>true</optional> and Gradle setup with developmentOnly, which prevent DevTools from flowing transitively into consuming modules. See the Spring Boot 3.0.x DevTools reference; verify dependency configuration against the version you use.
Spring Boot treats a fully packaged application as production and disables DevTools automatically in that mode; repackaged archives exclude it by default. The reference warns that forcing restart behavior on in production is a security risk. If you need to disable restart explicitly, exclude DevTools or set spring.devtools.restart.enabled=false. Do not set spring.devtools.restart.enabled=true in production.
If DevTools causes a restart or classloading problem
DevTools restart uses two classloaders, which can cause classloading issues, particularly in multi-module projects. To test whether restart is the cause, disable restart first; if needed, customize the restart classloader. Remote DevTools is a separate, special case that may require explicitly including the module in a packaged archive; that is not a reason to ship it by default.
Rank #4
A quick decision checklist
- Not deploying a container image? A regular executable jar may be all you need.
- Building container images with stable dependencies and frequently changing application files? Consider the layered archive or extraction workflow.
- Prefer fewer packaging steps and a simple
java -jarentry point? Use the single-jar pattern. - Have a complex multi-module build or dependencies sensitive to classpath order? Test the exploded layout and investigate classloader behavior if DevTools is involved.
- Need DevTools only while coding? Configure it as optional or development-only and rely on the production exclusion.
Match the Java runtime to your application
The Docker guide’s examples use eclipse-temurin:17, and its sample output reports Spring Boot 4.1.1 with Java 17.0.19. Those are example versions, not universal requirements. Choose a runtime image and Java version supported by the Spring Boot release your application uses.
The Tool Desk
Outbyte PC Repair FREERepair Windows errors before they cause bigger problemsFix Now →Outbyte Driver Updater FREEFix the driver behind crashes, sound loss and screen glitchesFind Drivers →Quick Recap
Best Value
Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.




