The usual development is that we deploy the project through the IDE, but sometimes we have to deploy it manually (for example, on the server).
Manual deployment is divided into the following steps:
1th Step: Use Maven to fight the war package (if the resulting war package is named: Appkit-web.war)
MVN Package
If you want to skip the test during the packaging process, use the following command:
MVN package-dmaven.test.skip=ture
2nd step: Copy the War package to the Tomcat-installed WebApps directory
CP Target/appkit-web.war ~/software/apache-tomcat-7.0.54/webapps/
3rd Step: Start Tomcat (my Tomcat's root directory is:/users/aborn/software/apache-tomcat-7.0.54)
./bin/catalina.sh Run
Then open the http://localhost:8080/appkit-web/index.html in the browser
Here is a problem, it is the default root directory is to add the project name, such as the appkit-web, so that some resource files are not loaded (because the resource file is the root directory as a relative path).
To modify this root directory, just modify the Tomcat server.xml configuration file (it's in conf/server.xml)
Add the following phrase between <Host> and </Host>
<context path= "/" docbase= "Appkit-web" debug= "0" privileged= "true"/> This configured path refers to the root directory, and DocBase refers to the war name.
So just open it on the browser: http://localhost:8080/index.html on the line.
<!--Tomcat Manager Context--
<context path= "/manager" docbase= "manager" debug= "0" privileged= "true"/>
Path= "" is the URL path to run after deployment, Docbase is the file name for your war. During the first run, Tomcat automatically extracts the war and generates a site with the name specified by path.
The "manager" in docbase here means that the war file name is called "Manager.war"
Modify Server.xml to deploy multiple Web projects under Tomcat
The first step:
Server.xml modified as follows:
Name="localhost" AppBase="WebRoot"
Unpackwars="True" Autodeploy="True"
Xmlvalidation="False" Xmlnamespaceaware="False">
<context Path=""DocBase="F:\myeclipse8work\teset\WebRoot"
Workdir="F:\java\tomcat-work" Reloadable="True">
</Context>
</Host>
Name="Zhangda"AppBase="WebRoot"
Unpackwars="True" Autodeploy="True"
Xmlvalidation="False" Xmlnamespaceaware= "false" >
<context path= docbase= " f:\myeclipse8work\hibernate\webroot "
workdir=" f:\ Java\tomcat-work2 " reloadable=" true " span class= "tag" >>
</context>
Worddir is a cache directory that sets different items, different items set different cache directories.
Step Two:
Locate the Hosts file under C:\Windows\System32\drivers\etc, and modify the following:
127.0.0.1 localhost
127.0.0.1 Zhangda
Remove the "#" from the front.
Step Three:
In Browser input: http://localhost:8080 can access F:\myeclipse8work\teset\WebRoot content.
In Browser input: http://zhangda:8080 can access F:\myeclipse8work\hibernate\WebRoot content.
Tomcat War Package deployment