Deploying my application at the root in Tomcat

后端 未结 10 1773
说谎
说谎 2020-11-22 06:25

I have the war file of my application. I need to deploy this at the root level. The current URL is http://localhost:8080/war_name/application_name.

相关标签:
10条回答
  • 2020-11-22 07:14

    The fastest way.

    1. Make sure you don't have ROOT app deployed, undeploy if you have one

    2. Rename your war to ROOT.war, deploy, thats all, no configuration changes needed

    0 讨论(0)
  • 2020-11-22 07:19

    You have a couple of options:

    1. Remove the out-of-the-box ROOT/ directory from tomcat and rename your war file to ROOT.war before deploying it.

    2. Deploy your war as (from your example) war_name.war and configure the context root in conf/server.xml to use your war file :

      <Context path="" docBase="war_name" debug="0" reloadable="true"></Context>
      

    The first one is easier, but a little more kludgy. The second one is probably the more elegant way to do it.

    0 讨论(0)
  • 2020-11-22 07:22

    In tomcat 7 with these changes, i'm able to access myAPP at / and ROOT at /ROOT

    <Context path="" docBase="myAPP">
         <!-- Default set of monitored resources -->
         <WatchedResource>WEB-INF/web.xml</WatchedResource>
    </Context>
    <Context path="ROOT" docBase="ROOT">
         <!-- Default set of monitored resources -->
         <WatchedResource>WEB-INF/web.xml</WatchedResource>
    </Context>
    

    Add above to the <Host> section in server.xml

    0 讨论(0)
  • 2020-11-22 07:25

    In my server I am using this and root autodeploy works just fine:

       <Host name="mysite" autoDeploy="true" appBase="webapps" unpackWARs="true" deployOnStartup="true">
            <Alias>www.mysite.com</Alias>
            <Valve className="org.apache.catalina.valves.RemoteIpValve" protocolHeader="X-Forwarded-Proto"/>
            <Valve className="org.apache.catalina.valves.AccessLogValve" directory="logs"
               prefix="mysite_access_log." suffix=".txt"
               pattern="%h %l %u %t &quot;%r&quot; %s %b"/>
            <Context path="/mysite" docBase="mysite" reloadable="true"/>
        </Host>
    
    0 讨论(0)
提交回复
热议问题