Skip to content
Related Articles

Related Articles

Improve Article
Create a New Maven Project from Command Prompt
  • Last Updated : 14 Dec, 2020

Maven is a powerful project management tool that is based on POM (project object model). It is used for projects build, dependency and documentation. It simplifies the build process like ANT. But it is too much advanced than ANT.
In short, maven is a tool that can be used for building and managing any Java-based project. Maven makes the day-to-day work of Java developers easier and generally help with the comprehension of any Java-based project.

Steps for creating a New Maven Project from Command Prompt:

Step 1: Open Run and type ‘cmd‘ to open Command Prompt.

Step 2: Using ‘cd’ command, you have to browse to the folder where you want to set up your project and then type the below command:



mvn archetype:generate -DgroupId=ToolsQA -DartifactId=DemoMavenProject -DarchetypeArtifactId=
maven-archetype-quickstart -DinteractiveMode=false

In the above command, you are using ‘DartifactId‘ i.e. your project name and ‘DarchetypeArtifactId‘ is the type of Maven project. There are different types of maven projects like web projects, java projects, etc.

Once you press Enter after typing the above command, it will start creating the Maven project

Step 3: After successfully building, once go to the project location to see the newly created maven project. Now open the pom.xml file, which resides in the project folder. By default, the POM is generated like this:

HTML




<!---contributed by sambhav228------>
    xsi:schemaLocation=
    <modelVersion>4.0.0</modelVersion>
    <groupId>ToolsQA</groupId>
    <artifactId>DemoMavenProject</artifactId>
    <packaging>jar</packaging>
    <version>1.0-SNAPSHOT</version>
    <name>DemoMavenProject</name>
    <url>http://maven.apache.org</url>
    <dependencies>
        <dependency>
            <groupId>junit</groupId>
            <artifactId>junit</artifactId>
            <version>3.8.1</version>
            <scope>test</scope>
        </dependency>
    </dependencies>
</project>

Step 4: In the folder structure of the Maven project you can find your DemoMavenProject.




My Personal Notes arrow_drop_up
Recommended Articles
Page :