Monday, July 31, 2017

Information on the Executable JAR in a spring boot application built using Maven

To understand what happens, it is a good practice to extract and see what the files included in a executable JAR built using Maven. Here I'm using the JAR built in
[1] http://ajanthane.blogspot.com/2017/07/getting-started-with-spring-boot-sample.html.

When we extract the JAR, we will see the below structure.


Below is the summarized contents of the above folders.


When we check the MANIFEST-INF file, then we can identify which class get invoked as entry point. The main use of the MANIFEST-INF file is:

  • Define the entry point of the Application, make the Jar executable.
  • Add project dependency classpath.

Here, specifically when we look at the below two lines:

Main-Class: org.springframework.boot.loader.JarLauncher
Start-Class: org.test.springboot.Application

That means the first class which get invoked is org.springframework.boot.loader.JarLauncher and then only it will start the main class we have specified, in our case org.test.springboot.Application.

More information on this can be found at [2].
[2] https://docs.spring.io/spring-boot/docs/current/reference/html/executable-jar.html

That's it...

No comments:

Post a Comment