Spring Boot Uber (Fat) Jar
In this tutorial, we will be discussing about the Uber JAR creation of a spring boot project. The Uber JAR is a JAR where all of the application's compiled code along with the dependencies are grouped together so, that the programmer may find easy if he needs to deploy it somewhere as the dependencies come along with the JAR. The Uber JAR is also known as Fat JAR. Let us work on the technique to generate the Uber JAR.
Creating Uber JAR for our Project:
It is very simple to generate an Uber JAR for a spring boot project because all you have to do is to include a plugin for the maven. The plugin has been included by default from the latest versions of spring-boot but in case it is not found under pom.xml then copy the below script and include in your pom.xml file.
<!-- This is used to define a comment in XML file -->
<!-- Other maven script like dependencies section -->
To our surprise, we have been generating the Uber jar automatically (If the plugin was included by default). Observe the below screenshot.
The Uber JAR is the JAR where all the application code along with dependencies (dependent JAR files) are grouped together in it. As a more practical view, we extracted the JAR file using software such as WinRAR on our file system and look at the below screenshots.
The above figure has a folder org where all the spring framework related dependencies are available and the above figure is the extraction of Uber JAR. In the Uber JAR, inside the META-INF folder we have the MANIFEST.MF file which holds basic meta information about your project and the BOOT-INF folder holds information of the class with the
@SpringBootApplication annotation which is the class from where execution begins.
Conclusion: In this tutorial, we have seen the importance of Uber JAR aka Fat JARand how to generate it in spring-boot.