Monday, May 19, 2014

eclipse maven-archetype-webapp tomcat


This blog post shows a step-by-step demonstration of how to create a simple maven based j2ee web application within eclipse using the m2e plugin. 

Before beginning, it might interest the reader to know that the lengthy process I'm about do describe can be circumvented by using the maven command, shown below, from the command line and importing the resulting pom into eclipse. 

mvn archetype:generate -DgroupId={your-groupid} -DartifactId={your-project-name} DarchetypeArtifactId=maven-archetype-webapp -DinteractiveMode=false

For this demo, you shall need:

Eclipse (kepler) with the maven m2e plugin and a stand alone instance of Tomcat (7+).




Create a new project using the File->New->Project... menu.


Select the "Maven Project" wizard.


Select project type and location as show below.


Select the archetype with a group id of: org.apache.maven.archetype and artifact id of: maven-archetype-webapp.



Create a group id and artifact id for your own project.


After pressing finish, it should be possible to see the newly created maven project in eclipse's project explorer as shown below:



Now associated the project with a sever so that you can run it from within eclipse by right clicking the new project and selecting "Run on Server" from the "Run As" menu.






Press finish and with some luck...


No comments:

Post a Comment