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.