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
.
相关问题
- Delete Messages from a Topic in Apache Kafka
- Jackson Deserialization not calling deserialize on
- How to maintain order of key-value in DataFrame sa
- StackExchange API - Deserialize Date in JSON Respo
- Difference between Types.INTEGER and Types.NULL in
In my server I am using this and root autodeploy works just fine:
Remove
$CATALINA_HOME/webapps/ROOT
. Update$CATALINA_HOME/conf/server.xml
, make sure that Host element look like the following text:It works with Tomcat 8. autoDeploy and deployOnStartup need to set to false to prevent tomcat from deploying
myApp
twice.Adding on to @Rob Hruska's sol, this setting in server.xml inside section works:
Note: override="true" might be required in some cases.
You have a couple of options:
Remove the out-of-the-box
ROOT/
directory from tomcat and rename your war file toROOT.war
before deploying it.Deploy your war as (from your example)
war_name.war
and configure the context root inconf/server.xml
to use your war file :The first one is easier, but a little more kludgy. The second one is probably the more elegant way to do it.
I know that my answer is kind of overlapping with some of the other answer, but this is a complete solution that has some advantages. This works on Tomcat 8:
This means that you only have to restart the tomcat once, and after updated war files can be deployed without a problem.
Step 1: In the server.xml file, find the connector entry and replace it with:
Step 2: Define contexts within the
<Host ...>
tag:Note that I addressed all apps in the webapp folder. The first effectively switch the root and the main app from position. ROOT is now on
http://example.com/ROOT
and the the main application is onhttp://example.com/
. The webapps that are password protected require theprivileged="true"
attribute.When you deploy a CAS.war file that matches with the root (
<Context path="/" docBase="CAS">
you have to reload that one in the admin panel as it does not refresh with the deployment.Do not include the
<Context path="/CAS" docBase="CAS">
in your contexts as it disables the manager option to deploy war files. This means that you can access the app in two ways:http://example.com/
andhttp://example.com/APP/
Step 3: In order to prevent unwanted access to the root and manager folder, add a
valve
to those context tags like this:This essentially limits access to the admin web app folder to people from my own domain (fake IP address) and localhost when they use the default port 8080 and maintains the ability to dynamically deploy the war files through the web interface.
If you want to use this for multiple apps that are using different IP addresses, you can add the IP address to the connector (
address="143.21.2.1"
).If you want to run multiple web apps from the root, you can duplicate the Service tag (use a different name for the second) and change the docbase of the
<Context path="/" docBase="CAS">
to for example<Context path="/" docBase="ICR">
.The fastest way.
Make sure you don't have ROOT app deployed, undeploy if you have one
Rename your war to ROOT.war, deploy, thats all, no configuration changes needed