I. Create a Web project 1.1 Choose Build Maven Project
Select File--New->maven Project, as shown in:
Click "Next" as shown:
Select WebApp and click "Next" as shown:
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 , Spring's 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.2 The document structure after the project is established
The file structure has just been created as shown in the following example:
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:
<project xmlns= "http://maven.apache.org/POM/4.0.0" xmlns:xsi= "Http://www.w3.org/2001/XMLSchema-instance"xsi:schemalocation= "http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd" > <modelversion>4.0.0</ Modelversion> <groupId>tqx</groupId> <artifactId>maven_study</artifactId> < Packaging>war</packaging> <version>0.0.1-SNAPSHOT</version> <name>maven_study maven Webapp</name> <url>http://maven.apache.org</url> <dependencies> <dependency> <groupId>junit</groupId> <artifactid>junit</ar tifactid> <version>3.8.1</version> <scope>test</scope> </dependency> </d Ependencies> <build> <!--related configuration information for automatically deploying Web projects to the Tomcat server-<finalname>maven_study</finalnam e> <plugins> <plugin> <groupId>org.codehaus.cargo</groupId> <artifactId>cargo-maven2-plugin</artifactId> <version>1.2.3</version> <configuration> <container> <!--indicates the version of the Tomcat server you are using-- <containerId>tomcat7x</containerId> <!--indicate the installation directory for the Tomcat server--> ; 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:
1.3. View the consoleAfter 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:
Address: http://localhost:8080/maven_study/index.jsp
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.
Maven Learning Tutorial (vii)------automatically deploy Web projects to Tomcat