Easy way to create maven web project

Maven is project and build management tool,which is used to take care of complete build life cycle in any java based applications. Any maven based application needs to follow certain directory structure that as shown below.

Maven provided a command to create this project structure easily,No need to create it manually. Need to execute following command in command prompt where we wanted to create the project.

mvn archetype:generate -DgroupId=com.test -DartifactId=SampleApp  -DarchetypeArtifactId=maven-archetype-webapp -DinteractiveMode=false

Here SampleApp is project name.After executing the above command we can find complete maven structure is created. Now project structure is ready but  we cannot use this project directly into eclipse because eclipse will not identify project until it has .project file. So in order to create .project and .classpath files execute the following command inside project where pom.xml resides.
mvn eclipse:eclipse -Dwtpversion=2.0

wepversion option informs maven that this project is web project and this project will be packed in the form of war file. Now project is ready we can import into eclipse to start use.


Post a Comment

Powered by Blogger.