Three ways to deploy Maven webapp to tomcat

After Maven has created a webapp project and deployed it to tomcat, there are three ways. If you know of other ways to deploy, you are welcome to add it.

The first is to copy the war package to the webapps directory of tomcat.

First select your project, right click-->Run As-->Maven install, as shown below:



    

 After the build is successful, find the project in the workspace, then find the war package in the target, and copy it to the webapps directory of tomcat to start it.

The second is to add a tomcat server in Eclipse, and then use this server to start the project.

Eclipse does not install tomcat server by default, you can select Server-->Server-->Next-->Apache-->Tomcat v7.0 Server-->Next in the upper left corner of Eclipse File-->New-->Other, and then select Finish the directory of Tomcat home, then the installation of tomcatServer is successful.

Then you can select the project, right click Run As --> Run on Server.

The third is to start with the XML file configured in tomcat's Catalina.

Select the project, right-click-->Properties, select Tomcat, check Is a Tomcat Project, then enter the project name in Context name, write /target/HelloWorld in the Subdirectrory to set as web application root (optional) box below, here The HelloWorld refers to the finalName of your pom.xml build. As shown below:



 Click Apply, then OK.

You can also create helloworld.xml in Tomcat's conf\Catalina\localhost with the following contents:

<Context path="helloworld" reloadable="true" docBase="E:\workspace\helloworld\target\helloworld" workDir="E:\workspace\helloworld\work" />

 

Before starting Tomcat, select the project Run As --> Maven install. After the build is successful, execute the cat diagram of the Tomcat plug-in in Eclipse to start Tomcat. The purpose of executing Maven install is to generate the helloworld folder in the target directory

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=326458640&siteId=291194637