How to manually deploy the Java project corresponding to the war package in Tomcat 7, tomcatwar
We usually deploy projects through IDE, but sometimes we have to perform manual deployment (for example, on the Server ).
Manual deployment involves the following steps:
Step 2: Use maven to pack war (if the obtained war package name is: appkit-web.war)
mvn package
To skip the test during packaging, run the following command:
mvn package -Dmaven.test.skip=ture
Step 2: copy the war package to the webapps directory installed in tomcat
cp target/appkit-web.war ~/software/apache-tomcat-7.0.54/webapps/
Step 2: start tomcat (my tomcat root directory is/Users/aborn/software/apache-tomcat-3rd)
./bin/catalina.sh run
Then open http: // localhost: 8080/appkit-web/index.html in the browser
There is a problem here. By default, the root directory needs to add the project name.Appkit-webIn this way, some resource files cannot be loaded (because the resource file uses the root directory as the relative path ).
To modify the root directory, you only need to modify the Tomcat server. xml configuration file (in conf/server. xml)
Add the following sentence between <Host> and </Host>:
<Context path="/" docBase="appkit-web" debug="0" privileged="true"/>
This configuration
PathIndicates that
Root directory, DocBase refers to the war name
In this way, you only need to open http: // localhost: 8080/index.html in the browser.