Maven Learning Total (vii) using MAVEN to create a Web project in--eclipse

Source: Internet
Author: User

I. Create a Web project 1.1 Choose Build Maven Project

Select File--New->project, as shown in:

  

in the New window, select Maven Project . 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, 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.5 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:

1 <Projectxmlns= "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>Ten   <Dependencies> One     <Dependency> A       <groupId>Junit</groupId> -       <Artifactid>Junit</Artifactid> -       <version>3.8.1</version> the       <Scope>Test</Scope> -     </Dependency> -   </Dependencies> -    +   <!--configuration information for automatically deploying Web projects to the Tomcat server - -   <Build> +       <!--Package The WebProject project into Webproject.war automatically deployed to the Tomcat server under the WebApps directory - A     <Finalname>WebProject</Finalname> at     <Plugins> -           <plugin> -               <groupId>Org.codehaus.cargo</groupId> -               <Artifactid>Cargo-maven2-plugin</Artifactid> -                 <version>1.2.3</version> -                 <Configuration> in                     <Container> -                           <!--indicates the version of the Tomcat server being used - to                         <Containerid>tomcat7x</Containerid> +                         <!--indicates the installation directory of the Tomcat server - -                         <Home>d:/apache-tomcat-7.0.53</Home> the                     </Container> *                     <Configuration> $                         <type>Existing</type>Panax Notoginseng                         <!--indicates the installation directory of the Tomcat server - -                         <Home>d:/apache-tomcat-7.0.53</Home> the                     </Configuration> +                 </Configuration> A                 <executions>   the                   <Execution>   +                       <ID>Cargo-run</ID>   -                       <Phase>Install</Phase>   $                       <Goals>   $                           <goal>Run</goal>   -                       </Goals>   -                   </Execution>   the               </executions> -           </plugin>Wuyi       </Plugins> the   </Build> - </Project>
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:

  

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.

Maven Learning Total (vii) using MAVEN to create a Web project in--eclipse

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.