Java 在apache tomcat中部署webapp文件夹以外的web应用程序
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/20064483/
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
Deploy web application other than webapp folder in apache tomcat
提问by Parth
I want to deploy web application in directory(e.g \Users\username\myapps\app1) other than webapps folder.
我想在 webapps 文件夹以外的目录(例如 \Users\username\myapps\app1)中部署 Web 应用程序。
I know to how to change "appBase" other than webapps by setting "appBase" attribute in "host" tag in server.xml in conf directory.
我知道如何通过在 conf 目录中 server.xml 的“host”标签中设置“appBase”属性来更改 webapps 以外的“appBase”。
But problem is, I don't want to change whole webapps directory, I just want to deploy one application not in webapps directory.
但问题是,我不想更改整个 webapps 目录,我只想部署一个不在 webapps 目录中的应用程序。
采纳答案by René Link
Use a context.xml
file placed in the $CATALINA_BASE/conf/[enginename]/[hostname]/
directory.
使用context.xml
放置在$CATALINA_BASE/conf/[enginename]/[hostname]/
目录中的文件。
enginename
->server.xml
-Server/Service/
Engine[@name]
Default isCatalina
.hostname
->server.xml
-Server/Service/Engine
Host[@name]
Default islocalhost
.
enginename
->server.xml
-Server/Service/
Engine[@name]
默认为Catalina
.hostname
->server.xml
-Server/Service/Engine
Host[@name]
默认为localhost
.
You can specify the absolute path or relative path in the docBase
attribute.
您可以在docBase
属性中指定绝对路径或相对路径。
<Context docBase="/Users/username/myapps/app1">
</Context>
See http://tomcat.apache.org/tomcat-7.0-doc/config/context.html
见http://tomcat.apache.org/tomcat-7.0-doc/config/context.html
PS (from the tomcat doc):
PS(来自tomcat doc):
It is NOT recommended to place elements directly in the server.xml file.This is because it makes modifying the Contextconfiguration more invasive since the main
conf/server.xml
file cannot be reloaded without restartingTomcat.
不建议将元素直接放置在 server.xml 文件中。这是因为它使修改Context配置更具侵入性,因为在不重新启动Tomcat 的情况下无法重新加载主
conf/server.xml
文件。