在 tomcat 7 中设置默认应用程序 [英] Setting default application in tomcat 7

查看:45
本文介绍了在 tomcat 7 中设置默认应用程序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经浏览了描述如何在 tomcat 中将给定 WAR(例如 abc.war)配置为默认 Web 应用程序的线程.

I've gone through the threads that describe how to configure a given WAR (say abc.war) as default web-app in tomcat.

要么

将 abc.war 重命名为 ROOT.war

Rename the abc.war to ROOT.war

在 ${tomcat.home}/conf/Catalina/localhost 中创建一个上下文 ROOT.xml,其中 path="" 并且 docBase 设置为战争的相对/绝对路径(保留 abc.war避免双重部署).

Create a context ROOT.xml in ${tomcat.home}/conf/Catalina/localhost with path="" and docBase set to relative/absolute path to the war (keeping the abc.war outside of webapps to avoid double deployment).

这两种解决方案都会在 webapps (appBase) 目录中生成 ROOT.war.但是我想在 webapps 中保留 WAR 名称 (abc.war) 并且没有单独的 ROOT.war 来实现这一点.

Both the solutions result in ROOT.war in webapps (appBase) directory. However I want to retain the WAR name (abc.war) in webapps and not have a separate ROOT.war to achieve this.

在我的案例中有效的一种解决方案是在 <Host> 下添加上下文.server.xml 中的标记.但根据 Tomcat 7 Doc ,不建议添加上下文直接在 server.xml 中.

One solution that worked in my case was adding a context under <Host> tag in server.xml . But as per Tomcat 7 Doc , it's not recommended to add context directly in server.xml.

有人能给我指出替代方案吗?

Could someone point me to an alternative?

谢谢.

推荐答案

详细方法

第一种方法:

首先关闭你的 tomcat [从 bin 目录 (sh shutdown.sh)] 然后你必须删除你的 tomcat webapps 文件夹中的所有内容 (rm -fr *) 然后将你的 WAR 文件重命名为 ROOT.war 最后启动你的 tomcat[来自bin目录(sh startup.sh)]

first shutdown your tomcat [from the bin directory (sh shutdown.sh)] then you must delete all the content of your tomcat webapps folder (rm -fr *) then rename your WAR file to ROOT.war finally start your tomcat [from the bin directory (sh startup.sh)]

第二种方法:

将您的战争文件保留在 CATALINA_BASE/webapps 中,以其原始名称 - 关闭autoDeploy 和 deployOnStartup 在 server.xml 文件的 Host 元素中.在 server.xml 中明确定义所有应用程序上下文,指定两个路径和文档库.你必须这样做,因为你已经禁用了所有的Tomcat自动部署机制,Tomcat 将不再部署您的应用程序除非它在 ​​server.xml 中找到它们的上下文.

leave your war file in CATALINA_BASE/webapps, under its original name - turn off autoDeploy and deployOnStartup in your Host element in the server.xml file. explicitly define all application Contexts in server.xml, specifying both path and docBase. You must do this, because you have disabled all the Tomcat auto-deploy mechanisms, and Tomcat will not deploy your applications anymore unless it finds their Context in the server.xml.

注意:

这最后一种方法也意味着为了对任何应用程序,您将不得不停止并重新启动Tomcat.

that this last method also implies that in order to make any change to any application, you will have to stop and restart Tomcat.

第三种方法:

将您的 war 文件放在 CATALINA_BASE/webapps 之外(它必须在以防止双重部署).- 在
中放置一个名为ROOT.xml的上下文文件CATALINA_BASE/conf//.此上下文文件中的单个元素必须具有docBase 属性指向您的 war 文件的位置.路径元素不应设置 - 它派生自 .xml 文件的名称,在此案例ROOT.xml.有关详细信息,请参阅上面的上下文容器.

Place your war file outside of CATALINA_BASE/webapps (it must be outside to prevent double deployment). - Place a context file named ROOT.xml in
CATALINA_BASE/conf//. The single element in this context file MUST have a docBase attribute pointing to the location of your war file. The path element should not be set - it is derived from the name of the .xml file, in this case ROOT.xml. See the Context Container above for details.

这篇关于在 tomcat 7 中设置默认应用程序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆