I. Create a Web project 1.1 Choose Build Maven Project
Select File--New->project, as shown in:
Select Maven---maven Project in the new window. Click "Next" as shown:
1.2 Select project Path
Select the storage directory for the project according to the actual situation of the project, or select the "Use default Workspace location" default workspace. As shown in the following:
1.3 Select project Type
Select Maven-archetype-webapp in the Artifact ID, as shown in:
1.4 Enter the group ID and Artifact ID and the package
Group IDs generally write large project names. The Artifact ID is the child project name.
For example, the Spring Web package, Group id:org.springframework,artifactid:spring-web.
Package is the default for you to build a bag, do not write or can. As shown in the following:
1.5 The document structure after the project is established
The file structure that was just created is as follows:
Ii. automatically deploy Web projects to Tomcat Server 2.1, configure the Tomcat server in the Pom.xml file
Configure the Web project's Pom.xml file with the following configuration:
1 <project xmlns= "http://maven.apache.org/POM/4.0.0" xmlns:xsi= "http://www.w3.org/2001/XMLSchema-instance" 2 xsi : schemalocation= "http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd" > 3 < Modelversion>4.0.0</modelversion> 4 <groupId>me.gacl.maven</groupId> 5 <artifactId> Webproject</artifactid> 6 <packaging>war</packaging> 7 <version>0.0.1-snapshot</version > 8 <name>webproject Maven webapp</name> 9 <url>http://maven.apache.org</url>10 <depen Dencies>11 <dependency>12 <groupid>junit</groupid>13 <artifactid>junit</arti factid>14 <version>3.8.1</version>15 <scope>test</scope>16 </dependency>1 7 </dependencies>18 <!--related configuration information for automatically deploying Web projects to the Tomcat server-->20 <build>21 <!--will Webprojec The T project is packaged into Webproject.war automatically deployed under the WebApps directory of the Tomcat server-->22 <finalname>webproject</finalname>23 <plugins>24 <plugin>25 <grou Pid>org.codehaus.cargo</groupid>26 <artifactid>cargo-maven2-plugin</artifactid>27 <version>1.2.3</version>28 <configuration>29 <containe R>30 <!--indicates the version of the Tomcat server used-->31 <containerid>tomcat7x< ;/containerid>32 <!--indicates the installation directory of the Tomcat server-->33 2.2. Publish the Web project to the WebApps directory of the TOMCA serverSelect the Web project (or select the Pom.xml file for the Web project) → "Run as" → "Maven install" as shown in:
After the Maven install command is executed, you can package the WebProject project into a Webproject.war package and publish it to the WebApps directory of the TOMCA server, as shown in:
Test the deployed Web project as shown in:
The browser normally outputs the contents of the Index.jsp page, which indicates that our deployment was successful. This is the process of automating the deployment of Web projects to a Tomcat server using Maven in Eclipse.
Automatically deploy Web projects to a Tomcat server using Maven in eclipse