java 如何在 Tomcat 启动期间禁止特定应用程序启动?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/5067062/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-10-30 09:15:31  来源:igfitidea点击:

How to disable specific apps from starting during Tomcat startup?

javatomcatdeployment

提问by BobbyF

My company is preparing a new production box while the current one is running. I would like to proactively install applications in Tomcat container of the new production box but would like to keep them disabled (similar to the feature present in Websphere) - this is very important because some of the applications poll for the data from the database and starting an application would interfere with current production deployment. They would be enabled at the time of production switch-over.

我的公司正在准备一个新的生产箱,而当前的生产箱正在运行。我想在新生产框的 Tomcat 容器中主动安装应用程序,但希望将它们禁用(类似于 Websphere 中存在的功能) - 这非常重要,因为某些应用程序从数据库中轮询数据并启动应用程序会干扰当前的生产部署。它们将在生产切换时启用。

How would I accomplish this? Any insight would be greatly appreciated.

我将如何做到这一点?任何见解将不胜感激。

回答by Alejandro Gil Sanda

You can simply rename de WEB-INF directory inside the webapp that you don't want to auto-start to some other name like Disabled-WEB-INF, before starting tomcat.

Disabled-WEB-INF在启动 tomcat 之前,您可以简单地将 web 应用程序中您不想自动启动的 WEB-INF 目录重命名为其他名称,例如, 。

Later on, if you wish to start that app, while tomcat is running, simply rename back the directory to WEB-INF.

稍后,如果您希望在 tomcat 运行时启动该应用程序,只需将目录重命名回 WEB-INF。

回答by clevertension

add deployIgnoreattribute in <Host>, and the value is the regular expression of the dirs you want to ignore, if you want to ignore foo,just set deployIgnore="foo"and you want to ignore more dirs,use regular expressions to set the values

在中添加deployIgnore属性<Host>,值为要忽略的目录的正则表达式,如果要忽略foo就设置deployIgnore="foo",如果想忽略更多的目录,使用正则表达式设置值

回答by niczan

You can use tomcat web application manager; this webapp does let you stop any application inside tomcat from running.

可以使用tomcat web应用管理器;这个 webapp 确实可以让你阻止 tomcat 中的任何应用程序运行。

回答by Bozho

In the <Host>element of your conf/server.xmlput deployOnStartup="false". Reference: Tomcat Host documentation

<Host>conf/server.xmlput的元素中deployOnStartup="false"。参考:Tomcat 主机文档