We are going to jump into creating first project! To create our first Maven project we are going to use Maven’s archetype mechanism. An archetype is defined as an original pattern or model from which all other things of the same kind are made.

In upcoming articles, we will dive deep into maven keywords (like what is POM, Archetype, GroupId, and so on..) and mechanism. In this article we are going to see how to create first maven project using following methods.

  1. From Command Prompt
  2. From Eclipse IDE
  3. From IntelliJ IDEA

Creating Maven Project from Command Prompt

In order to create the simplest of Maven projects, execute the following from the command line:

mvn -B archetype:generate \
    -DarchetypeGroupId=org.apache.maven.archetypes \
    -DgroupId=com.talksinfo.app \
    -DartifactId=my-app

Above command will start creating new maven project and will produce following result in command line,

[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
[INFO] No archetype defined. Using maven-archetype-quickstart (org.apache.maven.archetypes:maven-archetype-quickstart:1.0)
[INFO] ----------------------------------------------------------------------------
[INFO] Using following parameters for creating project from Old (1.x) Archetype: maven-archetype-quickstart:1.0
[INFO] ----------------------------------------------------------------------------
[INFO] Parameter: basedir, Value: E:\Workspace\MavenWorkspace
[INFO] Parameter: package, Value: com.talksinfo.app
[INFO] Parameter: groupId, Value: com.talksinfo.app
[INFO] Parameter: artifactId, Value: my-app
[INFO] Parameter: packageName, Value: com.talksinfo.app
[INFO] Parameter: version, Value: 1.0-SNAPSHOT
[INFO] project created from Old (1.x) Archetype in dir: E:\Workspace\MavenWorkspace\my-app
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 9.687 s
[INFO] Finished at: 2019-03-24T21:22:47+05:30
[INFO] ------------------------------------------------------------------------

Navigating to folder will have following structure,

 

Creating Maven Project using Eclipse IDE

In Eclipse, navigate to File-> New -> Maven Project (or) File -> New -> Project. While later gets you below screen and click on Next until Finish as in below steps.

Step 1:

Step 2:

Step 3:

Step 4:

Clicking on “Finish” creates new project with following structure with POM.xml

 

Creating Maven Project using IntelliJ IDEA

In IntelliJ IDEA, Click on create “New Project“, We are creating new project without selecting any archetype,

Step 1:

intelliJ maven project

Step 2:

Step 3:

Step 4:

Clicking on “Finish” creates new project with following structure with POM.xml

Conclusion

Hence we saw how to create new maven project from different terminals like command prompt, eclipse, intelliJ.

Reference

https://maven.apache.org/guides/getting-started/index.html

Please follow and like us:
error