3

We have a Spring Boot + Angular application. Currently we are packaging it as a jar and running it.

Is it ok to use the packaging as a JAR? Or should we move to a WAR type packaging. What would be the difference?

Swastik
  • 273
  • 3
  • 15
  • There is no difference in functionality. The difference is in choice of a server. If the embedded server packed with your Spring Boot app is good enough for you, then you are good to go. – Branislav Lazic Oct 26 '18 at 06:21
  • take a look here: you can tell spring-boot to create a war file which is self executable and deployable. So you can change your deployment if needed from embedded server to managed/provided server-environment: https://stackoverflow.com/questions/40289437/how-to-create-a-single-executable-war-in-spring-boot – the hand of NOD Oct 26 '18 at 07:53

3 Answers3

1

The difference is nothing else apart from the deployment style.

When using a JAR, the fat JAR that spring boot creates contains embedded tomcat.

If your team's deployment environment has a Application server like WebLogic or Websphere etc., which most enterprise environment try to choose as they already have license for these or any other such reasons, you would need to create a WAR.

For WAR:

Pros :

  • Creating a war is a safer option coz you can still deploy in any type of application or web server as required
  • Allows easy hook for DevOps to control start and stop of server if they already have setup for other teams that have application server setup.

Cons:

  • Extra config and setup if to be deployed in application/web server(s)
Karthik R
  • 5,523
  • 2
  • 18
  • 30
0

Spring Boot can 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.

Spring Boot can also be told to produce a JAR which includes all of your module/service's dependencies and can be run with java -jar .

DaveyDaveDave
  • 9,821
  • 11
  • 64
  • 77
  • Is there any advantage of choosing one over other? – Swastik Oct 26 '18 at 06:49
  • Depends on your deployment. If you are planning to deploy your application to an existing Java EE Application Server (e.g. Tomcat), then standard approach is to perform a war build.When you use fat jar approach, your application will be deployed on embedded application container provided by spring boo @Swastik – Nitheesh Chandran Oct 26 '18 at 06:58
-1

Easy way : You can go to your application.yml file and mention all environment profile details like below:

spring: profiles: default

spring: profiles: dev

spring: profiles: QA

spring: profiles: PROD

After in application.properties file just mention the active profile as below

spring.profiles.active=QA or Dev or prod