上QQ阅读APP看书,第一时间看更新
Creating a project with Maven
Once Maven is installed and verified, you will have to create a project with Maven. This you can do in the command prompt itself. Just run the following command in your desired location, then the project will be created automatically:
mvn archetype:generate -DgroupId=com.packtpub.restapp -DartifactId=ticket-management -DarchetypeArtifactId=maven-archetype-quickstart -DinteractiveMode=false -Dversion=1.0.0-SNAPSHOT
If you face any problems while creating the project, use the –X option in Maven, shown as follows. It will point out the location where the error has occurred:
mvn –X archetype:generate -DgroupId=com.packtpub.restapp -DartifactId=ticket-management -DarchetypeArtifactId=maven-archetype-quickstart -DinteractiveMode=false -Dversion=1.0.0-SNAPSHOT
In the following points, we go through each part of the command that is used to create a Maven project:
- archetype:generate: Use this if the goal is to create a new project on a specified archetype, in our case maven-archetype-quickstart.
- -Dgroupid=com.packtpub.restapp: This part defines a project with a group identifier such as a package.
- -DartifcatId=ticket-management: This part defines our project name (folder).
- -DarchetypeArtifactId=maven-archetype-quickstart: This part will be used to select the archetype on the archetype:generate goal.
- -Dversion=1.0.0-SNAPSHOT: The project version can be mentioned in this part. It will be helpful when you deploy the project and distribute it.