简体   繁体   English

Jar和War包装与嵌入式Tomcat的区别

[英]Difference between Jar and War packaging with embedded Tomcat

Spring Boot can build executable .jar or .war files. Spring Boot可以构建可执行的.jar.war文件。 Is there any difference between them, besides the file extension? 除文件扩展名外,它们之间有什么区别吗?

The documentation states You should configure your project to build a jar or war (as appropriate) . 文档说明You should configure your project to build a jar or war (as appropriate) For a Spring MVC web application, is in inappropriate (for technical reasons) to build an executable .jar instead of an executable .war ? 对于Spring MVC Web应用程序,由于技术原因而不适合构建可执行文件.jar而不是可执行文件.war

Generally speaking, when you're using an embedded container, you should stick to the defaults and build a jar file. 一般来说,当您使用嵌入式容器时,您应该坚持使用默认值并构建一个jar文件。

There are, however, two exceptions to that rule: 但是,该规则有两个例外:

  1. You want to use JSPs. 您想要使用JSP。 In that case you'll need to use war packaging as Tomcat's JSP support is tightly coupled to the layout of a war file. 在这种情况下, 您需要使用war包装,因为Tomcat的JSP支持与war文件的布局紧密耦合。
  2. You want to have the option of also deploying your application to a standalone container or app server. 您希望还可以选择将应用程序部署到独立容器或应用程序服务器。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM