java 在Tomcat 7中是否需要将context.xml复制到conf/Catalina/locahost中才能生效
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/12629557/
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
In Tomcat 7 do you need to copy context.xml into conf/Catalina/locahost for it to take effect
提问by Paul Taylor
Just moved from Tomcat 6 to Tomcat 7 and noticed that when you deploy a webapp called widget the META-INF/context.xml no longer get copied to conf/Catalina/localhost/widget.xml.
刚刚从 Tomcat 6 移到 Tomcat 7,并注意到当您部署一个名为 widget 的 webapp 时,META-INF/context.xml 不再被复制到 conf/Catalina/localhost/widget.xml。
What Im unclear about is whether it needs to be, will the settings in context.xml be used if left in META-INF or do they only have effect if moved to conf/Catalina/localhost/widget.xml
我不清楚的是是否需要,如果将 context.xml 中的设置留在 META-INF 中,是否会使用它们,或者它们是否仅在移动到 conf/Catalina/localhost/widget.xml 时才有效
Im using a vanilla tomcat 7 installation
我使用的是 vanilla tomcat 7 安装
回答by Frank Pavageau
See the documentation(my emphasis):
请参阅文档(我的重点):
Individual Context elements may be explicitly defined:
- In an individual file at
/META-INF/context.xml
inside the application files. Optionally (based on the Host'scopyXML
attribute) this may be copied to$CATALINA_BASE/conf/[enginename]/[hostname]/
and renamed to application's base file name plus a ".xml" extension.
可以明确定义单个 Context 元素:
- 在
/META-INF/context.xml
应用程序文件内的单个文件中。可选(基于主机的copyXML
属性)这可以被复制并重$CATALINA_BASE/conf/[enginename]/[hostname]/
命名为应用程序的基本文件名加上“.xml”扩展名。
The documentation for Hosthas this to say on copyXML
:
Host的文档有这样的说法copyXML
:
Set to true if you want a context XML descriptor embedded inside the application (located at
/META-INF/context.xml
) to be copied to xmlBase when the application is deployed. On subsequent starts, the copied context XML descriptor will be used in preference to any context XML descriptor embedded inside the application even if the descriptor embedded inside the application is more recent.The flag's value defaults to false. Note if deployXML is false, this attribute will have no effect.
如果您希望在
/META-INF/context.xml
部署应用程序时将嵌入应用程序(位于)的上下文 XML 描述符复制到 xmlBase,则设置为 true 。在后续启动时,复制的上下文 XML 描述符将优先于嵌入应用程序中的任何上下文 XML 描述符,即使嵌入应用程序中的描述符是更新的。该标志的值默认为 false。请注意,如果 deployXML 为 false,则此属性将无效。
回答by DarthPablo
As I understand it, the context.xml in META-INF is used unless the element deployXML is set to false
. Note from the Tomcat 7 docs, the default is true
unless a security manager is enabled!
据我了解,除非元素 deployXML 设置为 ,否则使用 META-INF 中的 context.xml false
。请注意Tomcat 7 docs,默认情况下,true
除非启用了安全管理器!
However, from the docs, I was under the impression that setting the copyXML
attribute in the context.xml itself (without touching server.xml) would cause the file to be copied to conf:
但是,从文档中,我的印象是copyXML
在 context.xml 本身中设置属性(不涉及 server.xml)会导致文件被复制到 conf:
<Context antiJARLocking="true" path="/widget" copyXML="true" />
However, using Tomcat 7, it seems that the file doesn't get copied to conf unless the copyXML
is set to true
on the as Frank answered above.
但是,使用 Tomcat 7,似乎文件不会被复制到 conf 除非copyXML
设置为true
上面 Frank 回答的那样。