Why Spring Boot by default packaging web applications as .jar ? Are there any advantages over .war ?
Shouldn't be all web applications packed as .war in order to be deployed to real web server ?
I thought that .jar files are for desktop applications whereas .war files are for web applications. since .jar doesn't contain web application components as mentioned here:
Java war vs. jar - what is the difference?
JAR files allow us to package multiple files in order to use it as a library, plugin, or any kind of application. On the other hand, WAR files are used only for web applications. The structure of the archives is also different. We can create a JAR with any desired structure.
Create an executable JAR file:Specify the manifest: Select the option Generate the manifest file. Seal content of the JAR file: select the option Seal JAR. Select the main class that acts as an entry point to the application: Click Browse button next to the text field Main Class.
You linked to a question about a WAR vs a JAR, while Spring boot's JAR is indeed a JAR, it contains more than what you usually put inside a JAR. Spring boot comes with an embedded servlet container, inside the JAR itself.
So the difference:
About your question:
Shouldn't be all web applications packed as .war in order to be deployed to real web server?
If you want to run a web application on an existing servlet container, you have to use a WAR file. But the Spring boot JAR comes with its own servlet container, so you can perfectly run it as well.
Which of the two you choose is your own choice. Even though Josh Long's mantra is "Make JAR, not WAR".
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With