gpt4 book ai didi

tomcat - 在 tomcat 7 中设置默认应用程序

转载 作者:行者123 更新时间:2023-11-28 21:45:01 24 4
gpt4 key购买 nike

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

要么

Rename the abc.war to ROOT.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 来实现这一点。

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

有人可以告诉我替代方案吗?

谢谢。

最佳答案

详细做法

第一种方法:

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)]

第二种方法:

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.

注意:

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

第三种方法:

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 - 在 tomcat 7 中设置默认应用程序,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14325171/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com