[英]Tomcat context.xml files, is there a hierarchy?
I am trying to use symbolic links in one of the applications I have running on Tomcat5.我试图在我在 Tomcat5 上运行的应用程序之一中使用符号链接。 Thanks to some help from another StackOverflow question I was able to do it by creating a context.xml file in
感谢另一个 StackOverflow 问题的帮助,我能够通过在
/...myapplication/META-INF/context.xml /...myapplication/META-INF/context.xml
I am now trying to implement this on a production server.我现在正在尝试在生产服务器上实现这一点。 However, there are other applications running on it.
但是,还有其他应用程序在其上运行。 And there is another context file
还有另一个上下文文件
/...tomcat/conf/context.xml /...tomcat/conf/context.xml
It seems to me these are setting configurations server-wide to all applications.在我看来,这些是为所有应用程序设置服务器范围的配置。 If I allowLinks in the conf/context.xml file, my symbolic links work.
如果我在 conf/context.xml 文件中允许链接,我的符号链接就起作用了。 If I don't allowLinks in conf/context.xml, my application's symbolic links do not work, even though I have allowed them in the META-INF/context.xml
如果我不允许 conf/context.xml 中的链接,即使我在 META-INF/context.xml 中允许它们,我的应用程序的符号链接也不起作用
My question is, does the conf/context.xml control all applications?我的问题是,conf/context.xml 是否控制所有应用程序? If I want symbolic links to work only in one application, do I need to remove the conf/context.xml and create new context files for each application?
如果我希望符号链接仅在一个应用程序中工作,是否需要删除 conf/context.xml 并为每个应用程序创建新的上下文文件? Or is there a way I can allow symbolic links in myapplication only?
或者有没有办法只允许我的应用程序中的符号链接?
See my answer to the " Which Tomcat 5 context file takes precedence " question.请参阅我对“ 哪个 Tomcat 5 上下文文件优先”问题的回答。
Regarding your specific allowLinks
question, the value in conf/context.xml
takes precedence by default.关于您的具体
allowLinks
问题,默认情况下conf/context.xml
的值优先。 If you say nothing in your conf/context.xml
, the default value is allowLinks="false"
in your conf/context.xml
.如果你说没有在你的
conf/context.xml
,默认值是allowLinks="false"
在你的conf/context.xml
。
If you want to change it only for your myapplication
, trying to say <Context allowLinks="true" ...>
in your META-INF/context.xml
will have no effect because normally the conf/context.xml
setting will take precedence.如果您只想为您的
myapplication
更改它,尝试在您的META-INF/context.xml
说<Context allowLinks="true" ...>
将不起作用,因为通常conf/context.xml
设置将优先.
But, if you say <Context allowLinks="true"
in your override="true" ...>
META-INF/context.xml
, then all your <Context>
settings in META-INF/context.xml
will be highest precedence, overriding anything in conf/context.xml
.但是,如果您在
META-INF/context.xml
说<Context allowLinks="true" override="true" ...>
,那么您在META-INF/context.xml
所有<Context>
设置都将是最高优先级,覆盖conf/context.xml
任何内容。
Finally, instead of a myapplication/WEB-INF/context.xml
file, I recommend using a conf/Catalina/localhost/myapplication.xml
file.最后,我建议使用
conf/Catalina/localhost/myapplication.xml
文件,而不是myapplication/WEB-INF/context.xml
文件。 This technique means you can keep the contents of your WEB-INF clean, which is the guts of your webapp -- I don't like to risk mucking about in the guts of my webapp.这种技术意味着您可以保持 WEB-INF 的内容干净,这是您的 web 应用程序的内脏——我不喜欢冒险在我的 web 应用程序内脏。 :-)
:-)
Just to add a point.只是补充一点。
Usually th meta-inf/context.xml is copied to the conf/Catalina/localhost/myapplication.xml通常将 meta-inf/context.xml 复制到 conf/Catalina/localhost/myapplication.xml
When redploying a war file the conf/Catalina/localhost/myapplication.xml is deleted and a new one copied in as described above.当重新部署一个 war 文件时,conf/Catalina/localhost/myapplication.xml 被删除,并如上所述复制一个新的。
This can be a real pain.这可能是一个真正的痛苦。 I like the idea of application specific context but I fail to see how having this in the meta-inf directory helps.
我喜欢应用程序特定上下文的想法,但我看不出在 meta-inf 目录中有什么帮助。
For Prod, UAT, etc this becomes a real pain.对于 Prod、UAT 等来说,这真的很痛苦。
So for anything server static but application specific it is better to put it in the conf/context.xml.因此,对于任何服务器静态但特定于应用程序的内容,最好将其放在 conf/context.xml 中。 Which has the negative that it holds context for several applications, touch one you inadvertently touch them all.
其不利之处在于它包含多个应用程序的上下文,触摸一个您会不经意间触摸它们。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.