In this section, you will learn to create a simple Java web application project from Maven Template.
Maven comes with 40+ Maven template projects for quick start. You can use any template to create your own project :
Follow the step to create a simple Java web application project from Maven template:
Step 1: Go to the folder where you want to generate the web
application. ex. C:\maven_template_project and run the command mvn
archetype:generate as follows :
| C:\maven_template_project>mvn
archetype:generate [INFO] Scanning for projects... [INFO] Searching repository for plugin with prefix: 'archetype'. [INFO] ------------------------------------------------------------------------ [INFO] Building Maven Default Project [INFO] task-segment: [archetype:generate] (aggregator-style) [INFO] ------------------------------------------------------------------------ [INFO] Preparing archetype:generate [INFO] No goals needed for project - skipping [INFO] Setting property: classpath.resource.loader.class => 'org.codehaus.plexus .velocity.ContextClassLoaderResourceLoader'. [INFO] Setting property: velocimacro.messages.on => 'false'. [INFO] Setting property: resource.loader => 'classpath'. [INFO] Setting property: resource.manager.logwhenfound => 'false'. [INFO] [archetype:generate {execution: default-cli}] [INFO] Generating project in Interactive mode [INFO] No archetype defined. Using maven-archetype-quickstart (org.apache.maven. archetypes:maven-archetype-quickstart:1.0) Choose archetype: 1: internal -> appfuse-basic-jsf (AppFuse archetype for creating a web applicati on with Hibernate, Spring and JSF) 2: internal -> appfuse-basic-spring (AppFuse archetype for creating a web applic ation with Hibernate, Spring and Spring MVC) 3: internal -> appfuse-basic-struts (AppFuse archetype for creating a web applic ation with Hibernate, Spring and Struts 2) 4: internal -> appfuse-basic-tapestry (AppFuse archetype for creating a web appl ication with Hibernate, Spring and Tapestry 4) 5: internal -> appfuse-core (AppFuse archetype for creating a jar application wi th Hibernate and Spring and XFire) 6: internal -> appfuse-modular-jsf (AppFuse archetype for creating a modular app lication with Hibernate, Spring and JSF) 7: internal -> appfuse-modular-spring (AppFuse archetype for creating a modular application with Hibernate, Spring and Spring MVC) 8: internal -> appfuse-modular-struts (AppFuse archetype for creating a modular application with Hibernate, Spring and Struts 2) 9: internal -> appfuse-modular-tapestry (AppFuse archetype for creating a modula r application with Hibernate, Spring and Tapestry 4) 10: internal -> maven-archetype-j2ee-simple (A simple J2EE Java application) 11: internal -> maven-archetype-marmalade-mojo (A Maven plugin development proje ct using marmalade) 12: internal -> maven-archetype-mojo (A Maven Java plugin development project) 13: internal -> maven-archetype-portlet (A simple portlet application) 14: internal -> maven-archetype-profiles () 15: internal -> maven-archetype-quickstart () 16: internal -> maven-archetype-site-simple (A simple site generation project) 17: internal -> maven-archetype-site (A more complex site project) 18: internal -> maven-archetype-webapp (A simple Java web application) 19: internal -> struts2-archetype-starter (A starter Struts 2 application with S itemesh, DWR, and Spring) 20: internal -> struts2-archetype-blank (A minimal Struts 2 application) 21: internal -> struts2-archetype-portlet (A minimal Struts 2 application that c an be deployed as a portlet) 22: internal -> struts2-archetype-dbportlet (A starter Struts 2 portlet that dem onstrates a simple CRUD interface with db backing) 23: internal -> struts2-archetype-plugin (A Struts 2 plugin) 24: internal -> shale-archetype-blank (A blank Shale web application with JSF) 25: internal -> maven-adf-archetype (Archetype to ease the burden of creating a new application based with ADF) 26: internal -> data-app (A new Databinder application with sources and resource s.) 27: internal -> jini-service-archetype (Archetype for Jini service project creat ion) 28: internal -> softeu-archetype-seam (JSF+Facelets+Seam Archetype) 29: internal -> softeu-archetype-seam-simple (JSF+Facelets+Seam (no persistence) Archetype) 30: internal -> softeu-archetype-jsf (JSF+Facelets Archetype) 31: internal -> jpa-maven-archetype (JPA application) 32: internal -> spring-osgi-bundle-archetype (Spring-OSGi archetype) 33: internal -> confluence-plugin-archetype (Atlassian Confluence plugin archety pe) 34: internal -> jira-plugin-archetype (Atlassian JIRA plugin archetype) 35: internal -> maven-archetype-har (Hibernate Archive) 36: internal -> maven-archetype-sar (JBoss Service Archive) 37: internal -> wicket-archetype-quickstart (A simple Apache Wicket project) 38: internal -> quickstart (A simple Apache Tapestry 5 Project) 39: internal -> scala-archetype-simple (A simple scala project) 40: internal -> lift-archetype-blank (A blank/empty liftweb project) 41: internal -> lift-archetype-basic (The basic (liftweb) project) 42: internal -> cocoon-22-archetype-block-plain ([http://cocoon.apache.org/2.2/m aven-plugins/]) 43: internal -> cocoon-22-archetype-block ([http://cocoon.apache.org/2.2/maven-p lugins/]) 44: internal -> cocoon-22-archetype-webapp ([http://cocoon.apache.org/2.2/maven- plugins/]) Choose a number: (1/2/3/4/5/6/7/8/9/10/11/12/13/14/15/16/17/18/19/20/21/22/23/2 4/25/26/27/28/29/30/31/32/33/34/35/36/37/38/39/40/41/42/43/44) 15: : 18 [INFO] artifact org.apache.maven.archetypes:maven-archetype-webapp: checking for updates from maven-archetype-webapp-repo [INFO] artifact org.apache.maven.archetypes:maven-archetype-webapp: checking for updates from central Downloading: http://repo1.maven.org/maven2/org/apache/maven/archetypes/maven-arc hetype-webapp/1.0/maven-archetype-webapp-1.0.jar Downloading: http://repo1.maven.org/maven2/org/apache/maven/archetypes/maven-arc hetype-webapp/1.0/maven-archetype-webapp-1.0.jar Downloading: http://repo1.maven.org/maven2/org/apache/maven/archetypes/maven-arc hetype-webapp/1.0/maven-archetype-webapp-1.0.jar Downloading: http://repo1.maven.org/maven2/org/apache/maven/archetypes/maven-arc hetype-webapp/1.0/maven-archetype-webapp-1.0.jar Define value for groupId: : net.roseindia Define value for artifactId: : roseindiaWebApp Define value for version: 1.0-SNAPSHOT: : 1.0 Define value for package: : testing Confirm properties configuration: groupId: net.roseindia artifactId: roseindiaWebApp version: 1.0 package: testing Y: : y Downloading: http://repo1.maven.org/maven2/org/apache/maven/archetypes/maven-arc hetype-webapp/1.0/maven-archetype-webapp-1.0.jar Downloading: http://repo1.maven.org/maven2/org/apache/maven/archetypes/maven-arc hetype-webapp/1.0/maven-archetype-webapp-1.0.jar Downloading: http://repo1.maven.org/maven2/org/apache/maven/archetypes/maven-arc hetype-webapp/1.0/maven-archetype-webapp-1.0.jar Downloading: http://repo1.maven.org/maven2/org/apache/maven/archetypes/maven-arc hetype-webapp/1.0/maven-archetype-webapp-1.0.jar Downloading: http://repo1.maven.org/maven2/org/apache/maven/archetypes/maven-arc hetype-webapp/1.0/maven-archetype-webapp-1.0.jar [INFO] ------------------------------------------------------------------------- --- [INFO] Using following parameters for creating OldArchetype: maven-archetype-web app:RELEASE [INFO] ------------------------------------------------------------------------- --- [INFO] Parameter: groupId, Value: net.roseindia [INFO] Parameter: packageName, Value: testing [INFO] Parameter: package, Value: testing [INFO] Parameter: artifactId, Value: roseindiaWebApp [INFO] Parameter: basedir, Value: C:\maven_template_project [INFO] Parameter: version, Value: 1.0 [INFO] ********************* End of debug info from resources from generated POM *********************** [INFO] OldArchetype created in dir: C:\maven_template_project\roseindiaWebApp [INFO] ------------------------------------------------------------------------ [INFO] BUILD SUCCESSFUL [INFO] ------------------------------------------------------------------------ [INFO] Total time: 1 minute 33 seconds [INFO] Finished at: Fri Jul 13 16:40:37 GMT+05:30 2012 [INFO] Final Memory: 9M/21M [INFO] ------------------------------------------------------------------------ |
You need to provide groupId, artifactId, version and value for package.
As you can see, there are 44 templates, you can choose any template by providing its sequence number :
The simple web application project created by this template is given below:

If you are facing any programming issue, such as compilation errors or not able to find the code you are looking for.
Ask your questions, our development team will try to give answers to your questions.
Ask Questions? Discuss: Create project from Maven Template
Post your Comment