Create a Simple Maven Project



Open Eclipse.
Create a new maven project. File--New--Other
New Wizard will open. There go to maven icon and expand it. Then Select Maven Project item.




Click Next.
In the New Maven Project wizard, select the create a simple project (skip archetype selection) check box.



Click Next
In the New Maven Project wizard enter the following values.


Group Id: org.test.testapp
Artifact Id: testapp
Version: 0.0.1-SNAPSHOT
Packaging: jar




Click Finish.

New Maven Project will be created and display in the Project Explore.
Here is the initial project structure of the created simple Maven project with a jar packaging. 




  Pom.xml file will contain the following initial details

<project>
 <modelVersion>4.0.0</modelVersion>
 <groupId>org.test.testapp</groupId>
 <artifactId>testapp</artifactId>
 <version>0.0.1-SNAPSHOT</version>
</project>








Run the Project

Executing Maven Goals.
Right Click on the testapp.
Select Run as
Here you can see the configured goals.
Maven install, Maven clean etc

maven install goal will install all the necessary dependancies inside pom.xml and create the packaging file which is jar or war file.

In this project we haven't done anything.

In the next post I will show you haow to create a simple spring-hibernate project.

After we creating the project inside eclipse we can run the application even through command line, if you have installed Apache Maven in to you PC.

For that you have to open commandline and go to the project directory thorugh command line and execute the mvn commands such as mvn clean, mvn install, etc.

ex: %testapp> mvn install


Comments

Murali said…
The example described was really helpful to me.
Could you please create a simple maven project and show the debug mode.

Thanks ,
Murali
Hi Murali,

I have added new post which is show to debug maven project.

I think it will help for you, if you any question, fell free to comment here.

Thank You,
Chandana
nico said…
thanks for the post. this seems to be a bit eclipse specific. i found a console version of this here: http://united-coders.com/phillip-steffensen/maven-2-part-1-setting-up-a-simple-apache-maven-2-project

i think it does the job, if you're for you, if you're not an eclipse user.

thanks.
Sandeep Kumar said…
A very nice article. Idea of explaining using snapshots is awesome. I would like to suggest following articles which can add more value to above article.

Steps to install Maven M2eclipse Core Components into Eclipse

Spring 3 MVC Eclipse Project using Maven
ADMIN said…
Really helpful, Thanks

Popular posts from this blog

XSLT - Modify Date and DateTime value

Integrate With Mutual Certificate Authentication based Service

Yield Price Sri Lanka - Android Application