简体   繁体   English

从Tomcat 8中的另一场战争开始.war文件

[英]Starting .war file from another war in Tomcat 8

Is there a way to start/stop .war file from inside another .war ? 有没有办法从另一个.war内部启动/停止.war文件?

I'm running SymmetricDS server using Tomcat 8 (it deploys it's own .war ) and I need to start it, when a button is pressed and Stop likewise. 我正在使用Tomcat 8运行SymmetricDS服务器(它部署它自己的.war ),我需要启动它,当按下按钮时同样停止。 Can I do that? 我能这样做吗?

When a war file is "dropped" into Tomcat's webapp folder, by default Tomcat automatically deploys it and starts it. 当war文件被“删除”到Tomcat的webapp文件夹中时,默认情况下Tomcat会自动部署并启动它。 When source war file is deleted from the webapp folder, Tomcat automatically stops and undeploys the webapp. webapp文件夹中删除源war文件时,Tomcat会自动停止并取消部署webapp。

So basically all you need to do is copy and delete the war file to/from the webapp folder to start/stop a webapplication. 因此,基本上您需要做的就是将war文件复制并删除到webapp文件夹以启动/停止Web应用程序。

Also (or if you can't do this) Tomcat has a built-in manager webapplication which is capable to deploy new applications (from war-files), or to stop and undeploy running web applications. 此外(或者如果你不能这样做)Tomcat有一个内置的管理器webapplication,它能够部署新的应用程序(来自war文件),或者停止和取消部署正在运行的web应用程序。
See Manager App HOW-TO for more details on this. 有关详细信息,请参阅Manager App HOW-TO

If you want to do this from your code, check out the ManagerServlet class. 如果要从代码中执行此操作,请查看ManagerServlet类。 You can call it with simple URLs and parameters. 您可以使用简单的URL和参数调用它。 The javadoc of the class contains example URLs what you can do with it. 该类的javadoc包含您可以使用它执行的示例URL。 Here are 2 important operations specifically to your needs: 以下是两项针对您需求的重要操作:

  • /start?path=/xxx - Start the web application attached to context path /xxx for this virtual host. /start?path=/xxx - 启动附加到此虚拟主机的上下文路径/ xxx的Web应用程序。
  • /stop?path=/xxx - Stop the web application attached to context path /xxx for this virtual host. /stop?path=/xxx - 停止附加到此虚拟主机的上下文路径/ xxx的Web应用程序。

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

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