Spring Boot将Web应用程序打包到.jar [英] Spring Boot package web application to .jar

查看:99
本文介绍了Spring Boot将Web应用程序打包到.jar的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

默认情况下,为什么Spring Boot将Web应用程序打包为 .jar ? .war有什么优势吗?

Why Spring Boot by default packaging web applications as .jar ? Are there any advantages over .war ?

不是所有的Web应用程序都打包为.war以便部署到真正的Web服务器上吗?

Shouldn't be all web applications packed as .war in order to be deployed to real web server ?

我认为.jar文件用于桌面应用程序,而.war文件用于Web应用程序.因为.jar不包含此处提到的Web应用程序组件:

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与jar的区别是什么?

推荐答案

您已链接到有关WAR与JAR的问题,而Spring boot的JAR确实是JAR,它包含的内容比通常放入JAR的内容还要多. Spring Boot带有嵌入式servlet.容器,位于

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.

所以区别:

  • JAR:通常包含资源/库/桌面应用程序/...
  • WAR:可以在Web容器上运行的Web应用程序
  • Spring boot fat JAR:一个在其自己的Web容器上运行的Web应用程序
  • A JAR: Usually contains resources/libraries/desktop applications/...
  • A WAR: A web application that can be run on a web container
  • The Spring boot fat JAR: A web application that runs on its own web container

关于您的问题:

不是所有的Web应用程序都打包为.war以便部署到真正的Web服务器上吗?

Shouldn't be all web applications packed as .war in order to be deployed to real web server?

如果要在现有servlet容器上运行Web应用程序,则必须

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.

您选择的两个是您自己的选择.即使乔什·朗(Josh Long)的口头禅是制造JAR,而不是战争".

Which of the two you choose is your own choice. Even though Josh Long's mantra is "Make JAR, not WAR".

这篇关于Spring Boot将Web应用程序打包到.jar的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆