Tuesday, February 23, 2016

Creating a Java project using maven using command line

First you need to have a install and properly configured maven instance. To check your installation copy issue this command  and check you are getting proper version details. 

mvn -version

if you are having difficulties in this please go through the steps mention in this link.

http://kingalawakatech.blogspot.com/2016/02/install-maven-in-cent-os.html

If all sounds great then we can jump in to creation of a project. 

Type following command to get started the project creation. Please make sure that you connected to the internet because in this maven project creation sometimes need to download some files from the internet. 

Before creating a project navigate to the location that you want to create this project.


mvn archetype:generate

This will prompt the type of projects that you can build from the maven and then you can select the number appropriate to your requirement. Then it will begin the project creation. In this creation process you will be asking for enter some details of the project. Such as group Id, artifact Id etc. This is a  small explanation about those parameters.

groupId : ID of the project group. (com.company.app)
artifactId : project name (myApp)
version : version of the project. (1.0)
package : this is the typical java package. please avoid keywords in this.

after giving those values you can successfully create new java project.

To clean the maven project you can use
maven clean 

To Build the project you can use 
maven package   

No comments:

Post a Comment