1. Use the following command to create a web application:
Code
MVN archetype: generate - Dgroupid = Net. Jianxi. tutorials. MAVEN
- Dartifactid = Webappdemo
- Dpackage = Net. Jianxi. tutorials. MAVEN
- Darchetypeartifactid = Maven - Archetype - Webapp
- Dversion = 1.0 - Dinteractivemode = No
The created web applicationProgramThe directory structure is as follows:
2. Run the following command to create a web packaging file:
MVN package
You can see the following directory structure:
3. Configure Pom. XML to run the web application directly.
This is the webappdemo generated in the previous step. war is directly published to the Web application server, such as Tomcat. to access your application. in Maven, you can directly configure POM to test your web application. XML supports jetty. the following is the 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 > Net. Jianxi. tutorials. MAVEN </ Groupid >
< Artifactid > Webappdemo </ Artifactid >
< Packaging > War </ Packaging >
< Version > 1.0 </ Version >
< Name > Webappdemo Maven webapp </ Name >
< URL > Http://maven.apache.org </ URL >
< Dependencies >
< Dependency >
< Groupid > JUnit </ Groupid >
< Artifactid > JUnit </ Artifactid >
< Version > 4.7 </ Version >
< Scope > Test </ Scope >
</ Dependency >
</ Dependencies >
< Build >
< Finalname > Webappdemo </ Finalname >
< Plugins >
< Plugin >
< Groupid > Org. mortbay. Jetty </ Groupid >
< Artifactid > Maven-jetty-plugin </ Artifactid >
</ Plugin >
</ Plugins >
</ Build >
</ Project >
In this way, you can run the following command to start your web application:
> MVN jetty: Run
Then you can access the Web application through: http: // localhost: 8080/webappdemo.
1. Use the following command to create a web application:
Code
MVN archetype: generate - Dgroupid = Net. Jianxi. tutorials. MAVEN
- Dartifactid = Webappdemo
- Dpackage = Net. Jianxi. tutorials. MAVEN
- Darchetypeartifactid = Maven - Archetype - Webapp
- Dversion = 1.0 - Dinteractivemode = No
The directory structure of the created web application is as follows:
2. Run the following command to create a web packaging file:
MVN package
You can see the following directory structure:
3. Configure Pom. XML to run the web application directly.
This is the webappdemo generated in the previous step. war is directly published to the Web application server, such as Tomcat. to access your application. in Maven, you can directly configure POM to test your web application. XML supports jetty. the following is the 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 > Net. Jianxi. tutorials. MAVEN </ Groupid >
< Artifactid > Webappdemo </ Artifactid >
< Packaging > War </ Packaging >
< Version > 1.0 </ Version >
< Name > Webappdemo Maven webapp </ Name >
< URL > Http://maven.apache.org </ URL >
< Dependencies >
< Dependency >
< Groupid > JUnit </ Groupid >
< Artifactid > JUnit </ Artifactid >
< Version > 4.7 </ Version >
< Scope > Test </ Scope >
</ Dependency >
</ Dependencies >
< Build >
< Finalname > Webappdemo </ Finalname >
< Plugins >
< Plugin >
< Groupid > Org. mortbay. Jetty </ Groupid >
< Artifactid > Maven-jetty-plugin </ Artifactid >
</ Plugin >
</ Plugins >
</ Build >
</ Project >
In this way, you can run the following command to start your web application:
> MVN jetty: Run
Then you can access the Web application through: http: // localhost: 8080/webappdemo.