cd g:\Java\Spring
And type the following command to create a Spring MVC project:mvn archetype:generate ^ -DarchetypeGroupId=co.ntier ^ -DarchetypeArtifactId=spring-mvc-archetype ^ -DarchetypeVersion=1.0.2Note that this command is quite long so I use the line-continuation character ^ (on Windows). On Linux, the line-continuation character is backslash (\):
mvn archetype:generate \ -DarchetypeGroupId=co.ntier \ -DarchetypeArtifactId=spring-mvc-archetype \ -DarchetypeVersion=1.0.2Depend on your Maven, it might download necessary JAR files from Maven’s central repository. And then it will be generating project in interactive mode – asking for your project’s information, for example:
Define value for property 'groupId': net.codejava Define value for property 'artifactId': MySpringMvc Define value for property 'version' 1.0-SNAPSHOT: : 1.0 Define value for property 'package' net.codejava: : net.codejavaThen it asks you to confirm (press Y to confirm):
Confirm properties configuration: groupId: net.codejava artifactId: MySpringMvc version: 1.0 package: net.codejava Y: : YOnce confirmed, Maven will generate your Spring MVC project (BUILD SUCCESS):
Project created from Archetype in dir: G:\Java\Spring\MySpringMvc
That means the Spring MVC project named MySpringMvc has been create successfully. Import this project in Eclipse, you will see the following project structure:
mvn archetype:generate ^ -DarchetypeGroupId=co.ntier ^ -DarchetypeArtifactId=spring-mvc-archetype ^ -DarchetypeVersion=1.0.2 ^ -DgroupId=net.codejava ^ -DartifactId=SpringMvcApp ^ -Dversion=1.0 ^ -Dpackage=net.codejava.spring ^ -DinteractiveMode=falseThat’s how to use Maven’s command to quickly create a Spring MVC project. You can also use the project as a guide to your first, hello world Spring MVC application.
Nam Ha Minh is certified Java programmer (SCJP and SCWCD). He began programming with Java back in the days of Java 1.4 and has been passionate about it ever since. You can connect with him on Facebook and watch his Java videos on YouTube.