How To Create A Maven Webapp In Eclipse?

I like Maven because it makes dependency resolution easier and I like Eclipse because it is lightweight (at least lighter than other Java IDEs) and configurable. But I hate when it comes to creating a Maven webapp in Eclipse because it is overly complicated. Till the time a simpler solution appears, here is what you need to do to create one:

  1. Make sure you have following items installed/configured in your Eclipse:
    1. WTP
    2. Tomcat (or any other servlet container)
    3. Maven Plugin
  2. Press Ctrl+N, select Maven Project and click Next.
  3. Click Next.
  4. In the Filter textfield, type maven-archetype-webapp. Select the archetype that appears in the box below and click Next.
  5. Type in Group Id (which could be same as root package of your app) and Artifact Id (which is the project name) and click Finish.
  6. Click your project name from Project Explorer (the tall pane on the left) and press Alt+Enter (it opens your project properties).
  7. Click Project Facets from the list on left hand side and then click “Convert to faceted form…” from the box on right hand side.
  8. Check and select “Dynamic Web Module” from facet list.
  9. Click the Runtimes tab on the right, check Apache Tomcat vX.0 and click Ok at the bottom of the dialog box.
  10. Select you project from Project Explorer and press Alt+Enter again.
  11. Select Deployment Assembly from the list on left hand side and click Add button from the box on right hand side.
  12. Select Java Build Path Entries, next, Maven Dependencies, finish and OK.

Published by

Umar Ashfaq

Umar Ashfaq is a full-stack web developer. His core strength is building neat UIs with JavaScript on web but he also enjoys server side Java, NodeJS and Objective C. Follow him on twitter @umarashfaq87

Leave a Reply

Your email address will not be published. Required fields are marked *