简体   繁体   English

如何将多个war文件重新部署到单个Spring Boot可部署jar中?

[英]How can I redeploy multiple war files into a single Spring Boot deployable jar?

Currently I'm deploying multiple war files into a Tomcat container. 目前,我正在将多个war文件部署到Tomcat容器中。 Is it possible to use Spring Boot to put all war files into a single deployable jar? 是否可以使用Spring Boot将所有war文件放入一个可部署的jar中? I know this is possible for a single app, but can it be done to deploy multiple apps that once were in separate war files? 我知道这对于单个应用程序是可行的,但是可以部署曾经位于单独战争文件中的多个应用程序吗?

Spring Boot by design will run one app (one war) per container. 根据设计,Spring Boot将在每个容器中运行一个应用程序(一场战争)。 If you want to go for the uber-jar deployment I suggest you stay with this since it is following also 12-factor-app best practices. 如果您想进行uber-jar部署,我建议您坚持使用它,因为它也遵循12要素应用最佳实践。

If you want to run multiple war files in one tomcat I suggest you follow the "old way" wrapping up your spring boot apps in war files and deploy them in an already set up tomcat or jetty or ... 如果您想在一个tomcat中运行多个war文件,建议您按照“旧方法”将spring boot应用程序包装在war文件中,然后将其部署在已设置的tomcat或jetty或...

So the answer will be: in principle – and with a lot of tweaking – you might be able to achieve what you are trying to do but this is not the intend of the jar distribution of spring boot apps. 因此,答案将是:原则上–通过大量的调整–您也许能够实现您想要做的事情,但这不是spring boot应用程序jar发行版的目的。 And always remember: work with the framework and not against it. 永远记住:使用框架而不是反对框架。

Tomcat container browses through the web apps and maps each war with the context root defined in it (single property of the web.xml). Tomcat容器浏览Web应用程序,并使用其中定义的上下文根(web.xml的单个属性)映射每次战争。 So, i do not think you can do merge the files in only one and still treat them as separate web apps. 因此,我认为您不能只合并一个文件,而仍然将它们视为单独的Web应用程序。

What can be done is to actually merge the code of the web apps in only war file and split the functionality based on different paths after the context root path. 可以做的是实际上仅将Web应用程序的代码合并到war文件中,并根据上下文根路径之后的不同路径拆分功能。

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

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