java 在上下文 Tomcat 7 上启用 autoDeploy

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/10017396/
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 23:16:43  来源:igfitidea点击:

Enable autoDeploy on context Tomcat 7

javatomcatcontext.xml

提问by BRabbit27

I've been reading that enabling the autoDeployoption will cause to hot deploy an app when putting a new war file. If I just want to set autoDeployin just one app and not in the entire server I'm supposed to enable it in <app>/META-INF/context.xmlam I right?

我一直在读到启用该autoDeploy选项将导致在放置新的War文件时热部署应用程序。如果我只想autoDeploy在一个应用程序中设置而不是在整个服务器中设置,我应该启用它,<app>/META-INF/context.xml对吗?

If so, the file should look like which one of the following?

如果是这样,该文件应类似于以下哪一项?

<?xml version="1.0" encoding="UTF-8"?>
<Context antiJARLocking="true" path="/TestApp">
    <autoDeploy>true</autoDeploy>
</Context>

or

或者

<?xml version="1.0" encoding="UTF-8"?>
<Context antiJARLocking="true" path="/SRC_RichFaces" autoDeploy="true">
</Context>

When I try either, there's a warning [SetContextPropertiesRule]{Context} Setting property 'autoDeploy' to 'true' did not find a matching property.

当我尝试任一时,都会出现警告 [SetContextPropertiesRule]{Context} Setting property 'autoDeploy' to 'true' did not find a matching property.

Any advice?

有什么建议吗?

UPDATE

更新

Sorry for the inconvenience, I misunderstood the documentation. I have to enable the <Host>attribute autoDeploy.

很抱歉给您带来不便,我误解了文档。我必须启用该<Host>属性autoDeploy

So I should have in the context.xmlsomething like

所以我应该在context.xml 中有类似的东西

<?xml version="1.0" encoding="UTF-8"?>
<Context antiJARLocking="true" path="/TestApp"/>
<Host autoDeploy="true"/>

am I right?

我对吗?

回答by Mark Thomas

You can not do what you are trying to do. autoDeploy is only configurable per Host, not per Context.

你不能做你想做的事。autoDeploy 只能按主机配置,不能按上下文配置。

The closest you could get is to enable autoDeploy for the Host's appBase and place the apps where you want autoDeploy enabled in the appBase and the other applications outside the appBase. These would then need to be deployed by adding context.xml elements under $CATALINA_BASE/Catalina/localhost

您可以获得的最接近的是为主机的 appBase 启用 autoDeploy,并将应用程序放置在 appBase 中要启用 autoDeploy 的位置,并将其他应用程序放置在 appBase 之外。然后需要通过在 $CATALINA_BASE/Catalina/localhost 下添加 context.xml 元素来部署这些

E.g. to deploy my app this way you'd create the file:
$CATALINA_BASE/Catalina/localhost/myapp.xml
with the contents:

例如,以这种方式部署我的应用程序,您将创建文件:
$CATALINA_BASE/Catalina/localhost/myapp.xml
,其内容如下:

<Context docBase="/absolute/path/to/myapp.war" >