1
votes

I'm new to Spring Boot and I saw executable jar about spring-boot. it says:

Executable jars and Java

Java does not provide any standard way to load nested jar files (i.e. jar files that are themselves contained within a jar). This can be problematic if you are looking to distribute a self-contained application.

To solve this problem, many developers use “uber” jars. An uber jar simply packages all classes, from all jars, into a single archive. The problem with this approach is that it becomes hard to see which libraries you are actually using in your application. It can also be problematic if the same filename is used (but with different content) in multiple jars.

Spring Boot takes a different approach and allows you to actually nest jars directly.

I want to know if uber jars or fat jars has some disadvantages,i.e.we must redeploy entire uber-jars,may run into trouble about NoSuchMethodError.How is Spring boot executable jar diffent from uber jars. Since it has many disadvantages why does spring boot still use this type of jar?

1

1 Answers

3
votes

With Spring Boot you use spring-boot-maven-plugin or spring-boot-gradle-plugin, which repackages your JAR with all the dependencies. This is called fat JAR. This is different than uber JAR.

Spring Boot packaging: JAR archive containing dependencies as JAR. Uber JAR: JAR archive containing compiled class files of all dependencies.

So Spring Boot is like WAR with embedded tomcat. So that you can execute it as JAR. This turns to be most modern approach to host cloud native applications.

You can theoretically get NoSuchMethodError if you are using have transitive dependencies of API incompatible versions, but this problem is present with WAR packaging also.