Maven notes (4)-build a web project

Source: Internet
Author: User

1. Enter the command line and execute:

 
MVN archetype: generate-dgroupid = cn. luxh. app-dartifactid = My-web-app-darchetypeartifactid = Maven-Archetype-webapp-dinteractivmode = false

You can press enter to confirm the version number. The following prompt is displayed when the build is successful.

Under the current user directory, the generated web project directory structure is as follows:

2. Of course, this empty project has only one index. jsp page, which is packaged, published, and run.

1) switch to the my-web-app directory through the command line and execute MVN package. After the build is successful, a target directory is added to the my-web-app directory, in this directory will be packaged into a my-web-app.war, copy the war package to the Tomcat release directory can run.

2) Integrate jetty for release and run. You need to configure Pom. xml.

 < 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  > CN. luxh. app </  Groupid  >    <  Artifactid  > My-web-app </  Artifactid  >    <  Packaging  > War </ Packaging  >  <! --  Web project default packaging method war  -->    <  Version  > 1.0-Snapshot </  Version  >    <  Name  > My-web-app Maven webapp </  Name >    <  URL  > Http://maven.apache.org </  URL  >    <  Dependencies  >      <  Dependency  >        <  Groupid  > JUnit</  Groupid  >        <  Artifactid  > JUnit </  Artifactid  >        <  Version  > 3.8.1 </  Version  >        < Scope  > Test </  Scope  >      </  Dependency  >    </  Dependencies  >    <  Build  >      <  Finalname  > My-web-app </  Finalname  >          <  Pluginmanagement  >      <! --  Configure Jetty  -->        <  Plugins  >          <  Plugin  >           <  Groupid > Org. mortbay. Jetty </  Groupid  >              <  Artifactid  > Maven-jetty-plugin </  Artifactid  >          </  Plugin  >        </  Plugins  > </  Pluginmanagement  >        </  Build  >    </  Project  > 

Run MVN jetty: Run to access the application on port 8080.

 

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.