Exporting a war using Eclpise
1. Right-click on the item that needs to be packaged > select [Export]
2. Select [WAR file] under [Web] and click [Next]
3. Select Save path via [Browse] and click [Finish] to finish .
Exporting a war using Maven
1. Through Eclipse mode: Select the [Maven install] for the project you want to package right-click [Run as]. When prompted successfully, the path of the war package is displayed, typically under the target directory of the project.
2. Through the MAVEN command: the console enters the project directory and executes the MVN Package command. The path to the generated war package will be prompted after success. Typically in the target directory of the project.
Note: Pom.xml's <packaging/> configuration is a war package after the war is packaged, and the jar package is packaged when configured as a jar. Both the MVN Package command and the MVN install command can be packaged. My project name here is tsj-spring, so the default name is Tsj-spring.war.
Deploy the war package to Tomcat
1. Place the Tsj-spring.war in the Tomcat WebApps directory.
2. Configuring the Conf\server.xml file
Add in <Host>:
<Context docBase="tsj-spring" path="/tsj-spring" reloadable="false" source="org.eclipse.jst.jee.server:tsj-spring"/>1
<textarea spellcheck="false" style="position: absolute; bottom: -1em; padding: 0px; width: 1000px; height: 1em; outline: none" tabindex="0" readonly=""></textarea>1
< Context docBase="tsj-spring"path="/tsj-spring"reloadable="false" Source="org.eclipse.jst.jee.server:tsj-spring"/>
2
1
3. Launch Tomcat, double-click on the Startup.bat in the bin directory to access the project directly in the browser after successful startup.
Note: The war file is automatically decompressed when Tomcat is started, so it is also the same when deploying a project to put the Web project's compiled files directly in WebApps.
Encounter problems
1. If you encounter error message: Package javax.servlet.http does not exist import javax.servlet.http.HttpServletRequest;
Workaround: Copy the Servlet-api.jar from the Tomcat\lib directory to the Java\jdk1.8.0_51\jre\lib\ext directory of the JDK.
2. Are you wondering what the difference is between [mvn install] and [MVN package]? The first diagram below executes [MVN package], and the second graph executes [mvn install]. Obviously [mvn install] does one more thing besides packing: Install your packaged files in a local repository.
Source: http://blog.csdn.net/taoshujian/article/details/75570780
Export a Java Web project to a war package and deploy it to Tomcat