[英]Deploy WAR or “fat” JAR?
I'm noticing a lot of projects (DropWizard, Grails, etc.) starting to embrace the notion of a "fat" JAR (using an embedded web server like Jetty or Tomcat) vs. the traditional WAR deploy. 我注意到许多项目(DropWizard,Grails等)开始接受“胖”JAR(使用Jetty或Tomcat等嵌入式Web服务器)与传统WAR部署的概念。 Both methods involve a single JVM process (ie no matter how many WARs are deployed to Tomcat, it's all the same JVM process). 这两种方法都涉及单个JVM进程(即无论将多少WAR部署到Tomcat,它都是相同的JVM进程)。
Under what circumstances is either deployment method preferable over the other? 在什么情况下,哪种部署方法优于另一种?
Here are some reasons: 以下是一些原因:
In favor of JAR: 赞成JAR:
In favor of WAR or EAR: 赞成WAR或EAR:
Having said this, you can always provide 2 or 3 types of executables to cater to all needs. 话虽如此,您始终可以提供2种或3种类型的可执行文件,以满足所有需求。 Any build tool makes this easy. 任何构建工具都可以轻松实现。
Distributing an application with an embedded webserver allows for standalone setup and running it by just calling java -jar application.jar
. 使用嵌入式Web服务器分发应用程序允许独立设置并通过调用java -jar application.jar
运行它。
However, there may be users who want to be in control of which web server is used or who want to deploy multiple applications into a single webserver (eg in order to prevent port clashes especially with ports 80 and 8080). 但是,可能存在希望控制使用哪个Web服务器或者想要将多个应用程序部署到单个Web服务器中的用户(例如,为了防止端口冲突,尤其是端口80和8080)。 In that case a "fat" jar might cause problems or at least some unneeded code and thus a larger memory footprint. 在这种情况下,“胖”jar可能会导致问题或至少一些不需要的代码,从而导致更大的内存占用。
IMHO the best approach for those two cases would be to provide two artifacts: a "fat" jar for (easier) standalone setup and an application-only war/ear for those who want to deploy the application in their own container. 恕我直言,这两种情况的最佳方法是提供两个工件:一个用于(更简单)独立设置的“胖”jar和一个仅应用程序的战争/耳朵,用于那些想要在自己的容器中部署应用程序的人。
I am thinking about user perspective. 我正在考虑用户的观点。 You could wrap this one-self containing jar within a .exe or .dmg and just install it without the need to have additional instructions on how to deploy. 您可以将这个包含自己的jar 包装在.exe或.dmg中,只需安装它就可以不需要有关于如何部署的其他说明。 Also, since you are doing the deploy for a particular server only, you could take advantage of that particular server 此外,由于您仅为特定服务器进行部署,因此您可以利用该特定服务器
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.