【问题标题】:Tomcat 7 not auto unpacking warTomcat 7 不会自动解包战争
【发布时间】:2018-04-27 13:21:13
【问题描述】:

我想将我的应用程序部署为根应用程序,因此我将我的战争重命名为 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 也从添加上下文标记的路径后正确呈现。所以也不想改变这种行为。

【问题讨论】:

    标签: tomcat7 war


    【解决方案1】:

    看起来我们不能这样做。我们不能在同一主机下有两个具有相同路径和不同 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

    【讨论】:

      猜你喜欢
      • 2014-04-28
      • 2017-02-01
      • 2012-11-27
      • 2016-11-06
      • 2020-09-24
      • 1970-01-01
      • 1970-01-01
      • 2015-03-12
      • 1970-01-01
      相关资源
      最近更新 更多