Differences between jar and war in Spring Boot?

Hama Saadwn picture Hama Saadwn · Jul 18, 2017 · Viewed 35.7k times · Source

I'm about to build my first website in Java with Spring Framework using Spring Boot and it's much easier to build it in jar, but I have a few questions about it.

What are the differences in general?

In jar files the views are under /resources/templates, but in war file it's under /webapp/WEB-INF/.

What are the differences? Can I deploy a jar on an online host?

Answer

glytching picture glytching · Jul 18, 2017

Spring Boot can be told to produce a 'fat JAR' which includes all of your module/service's dependencies and can be run with java -jar <your jar>. See "Create an executable JAR with Maven" here.

Spring Boot can also be told to produce a WAR file, in which case you'll likely choose to deploy it to a web container such as Tomcat or Jetty.

Plenty more details on Spring Boot deployment here.