Deploying Spring Boot in Production

对着背影说爱祢 提交于 2020-08-07 09:23:43

问题


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?


回答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)



回答2:


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 .




回答3:


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



来源:https://stackoverflow.com/questions/53002502/deploying-spring-boot-in-production

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!