Tomcat 7 不自动解包war

Tomcat 7 not auto unpacking war

我想将我的应用程序部署为根应用程序,因此我将 war 重命名为 ROOT.war。默认 server.xml 看起来像 -

  <Host name="localhost"  appBase="webapps"
        unpackWARs="true" autoDeploy="true">

    <!-- SingleSignOn valve, share authentication between web applications
         Documentation at: /docs/config/valve.html -->
    <!--
    <Valve className="org.apache.catalina.authenticator.SingleSignOn" />
    -->

    <!-- Access log processes all example.
         Documentation at: /docs/config/valve.html
         Note: The pattern used is equivalent to using pattern="common" -->
    <Valve className="org.apache.catalina.valves.AccessLogValve" directory="logs"
           prefix="localhost_access_log." suffix=".txt"
           pattern="%h %l %u %t &quot;%r&quot; %s %b" />

  </Host>

我还需要提供一些静态内容。所以我添加了上下文标签-

  <Host name="localhost"  appBase="webapps"
        unpackWARs="true" autoDeploy="true">

    <!-- SingleSignOn valve, share authentication between web applications
         Documentation at: /docs/config/valve.html -->
    <!--
    <Valve className="org.apache.catalina.authenticator.SingleSignOn" />
    -->

    <Context docBase="/home/athakur/Documents/UI" path="/" />

    <!-- Access log processes all example.
         Documentation at: /docs/config/valve.html
         Note: The pattern used is equivalent to using pattern="common" -->
    <Valve className="org.apache.catalina.valves.AccessLogValve" directory="logs"
           prefix="localhost_access_log." suffix=".txt"
           pattern="%h %l %u %t &quot;%r&quot; %s %b" />

  </Host>

我想提供此路径中的静态内容和我的 ROOT.war 中的 api。但是一旦我添加上下文元素 ROOT.war 就不会扩展和部署。当我删除它的上下文路径时。 UI 也从添加上下文标记的路径 post 正确呈现。所以也不想改变这种行为。

看来我们不能这样做。我们不能在同一主机下有两个具有相同路径和不同 docBase 的上下文。所以你不能有 -

<Context docBase="/home/athakur/Documents/UI" path="/" />
<Context docBase="ROOT" path="/" />

所以我不得不接受

<Context docBase="/home/athakur/Documents/UI" path="/" />
<Context docBase="ROOT" path="/apis" />

但是,如果您只想在根级别执行此操作,则需要从您的 webapp 内部执行此操作。 文档 - https://tomcat.apache.org/tomcat-8.0-doc/config/context.html