Maven Learning Tutorial (vii)------automatically deploy Web projects to Tomcat

Source: Internet
Author: User

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--&gt                        ; 2.2. Publish the Web project to the WebApps directory of the TOMCA server

Select the Web project (or select the Pom.xml file for the Web project) → "Run as" → "Maven install" as shown in:

1.3. View the console

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:

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

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.