How to manually deploy the Java project corresponding to the war package in Tomcat 7, tomcatwar

Source: Internet
Author: User

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.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.