In this tutorial we will learn to create a maven project using command prompt
Prerequisites
- Java installed If not Refer: https://beginnersbug.com/how-to-install-java-in-windows/
- JAVA_HOME : If not refer : https://beginnersbug.com/how-to-set-java-home-in-windows/
- M2_HOME If not refer : https://beginnersbug.com/set-maven-home-in-windows/
Syntax
mvn archetype:generate -DgroupId= -DartifactId= -DarchetypeArtifactId=maven-archetype-quickstart -DinteractiveMode=false
Sample
mvn archetype:generate -DgroupId=com.beginnergsbug -DartifactId=sample-project -DarchetypeArtifactId=maven-archetype-quickstart -DinteractiveMode=false
Output
C:\Users\USHA RAJESH\Desktop\sample>mvn archetype:generate -DgroupId=com.beginnergsbug -DartifactId=sample-project -DarchetypeArtifactId=maven-archetype-quickstart -DinteractiveMode=false
[INFO] Scanning for projects...
[INFO]
[INFO] ------------------< org.apache.maven:standalone-pom >-------------------
[INFO] Building Maven Stub Project (No POM) 1
[INFO] --------------------------------[ pom ]---------------------------------
[INFO]
[INFO] >>> maven-archetype-plugin:3.0.1:generate (default-cli) > generate-sources @ standalone-pom >>>
[INFO]
[INFO] <<< maven-archetype-plugin:3.0.1:generate (default-cli) < generate-sources @ standalone-pom <<<
[INFO]
[INFO]
[INFO] --- maven-archetype-plugin:3.0.1:generate (default-cli) @ standalone-pom ---
[INFO] Generating project in Batch mode
Downloading from central: https://repo.maven.apache.org/maven2/org/apache/maven/archetypes/maven-archetype-quickstart/1.0/maven-archetype-quickstart-1.0.pom
Downloaded from central: https://repo.maven.apache.org/maven2/org/apache/maven/archetypes/maven-archetype-quickstart/1.0/maven-archetype-quickstart-1.0.pom (703 B at 1.5 kB/s)
Downloading from central: https://repo.maven.apache.org/maven2/org/apache/maven/archetypes/maven-archetype-bundles/2/maven-archetype-bundles-2.pom
Downloaded from central: https://repo.maven.apache.org/maven2/org/apache/maven/archetypes/maven-archetype-bundles/2/maven-archetype-bundles-2.pom (1.5 kB at 3.5 kB/s)
Downloading from central: https://repo.maven.apache.org/maven2/org/apache/maven/archetype/maven-archetype-parent/1/maven-archetype-parent-1.pom
Downloaded from central: https://repo.maven.apache.org/maven2/org/apache/maven/archetype/maven-archetype-parent/1/maven-archetype-parent-1.pom (1.3 kB at 2.9 kB/s)
Downloading from central: https://repo.maven.apache.org/maven2/org/apache/maven/archetypes/maven-archetype-quickstart/1.0/maven-archetype-quickstart-1.0.jar
Downloaded from central: https://repo.maven.apache.org/maven2/org/apache/maven/archetypes/maven-archetype-quickstart/1.0/maven-archetype-quickstart-1.0.jar (4.3 kB at 7.6 kB/s)
[INFO] ----------------------------------------------------------------------------
[INFO] Using following parameters for creating project from Old (1.x) Archetype: maven-archetype-quickstart:1.0
[INFO] ----------------------------------------------------------------------------
[INFO] Parameter: basedir, Value: C:\Users\USHA RAJESH\Desktop\sample
[INFO] Parameter: package, Value: com.beginnergsbug
[INFO] Parameter: groupId, Value: com.beginnergsbug
[INFO] Parameter: artifactId, Value: sample-project
[INFO] Parameter: packageName, Value: com.beginnergsbug
[INFO] Parameter: version, Value: 1.0-SNAPSHOT
[INFO] project created from Old (1.x) Archetype in dir: C:\Users\USHA RAJESH\Desktop\sample\sample-project
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 12.855 s
[INFO] Finished at: 2020-01-31T09:17:42+05:30
[INFO] ------------------------------------------------------------------------
C:\Users\USHA RAJESH\Desktop\sample>
Syntax Explanation
mvn maven base command
archetype:generate= to generate a maven project
-DgroupId= group id for the project
-DartifactId= artifact id it is similar to project name
-DarchetypeArtifactId= type of archetype
-DinteractiveMode= true/false
Related Articles
How to install Apache Maven in windows