Create a Project with Maven for Eclipse

Install & configure Maven from http://maven.apache.org/download.html.

Go to eclipse workspace and run the following command

mvn archetype:create -DgroupId=com.mycompany.projectname -DartifactId=projectname -DarchetypeArtifactId=maven-archetype-webapp

-DartifactId is your project name and -DgrouipId is your package.
Change the ‘com.mycompany.app’ and ‘my-app’ as you want them to be.
The command will download necessary poms & jars and create the folder architecture with a very basic pom.xml file.

Now, we will make it an eclipse project so that we can import it from eclipse. Go to the project folder. Run

cd my-app
mvn eclipse:eclipse -Dwtpversion=2.0

This will generate eclipse .classpath & .project file. So open eclipse and just import the project.

To make a web project change jar to war in pom.xml and run

mvn eclipse:clean eclipse:eclipse -DdownloadSources=true -DdownloadJavadocs=true -Dwtpversion=2.0

Refer this article for more.

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: