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:
- Make sure you have following items installed/configured in your Eclipse:
- WTP
- Tomcat (or any other servlet container)
- Maven Plugin
- Press Ctrl+N, select Maven Project and click Next.
- Click Next.
- In the Filter textfield, type maven-archetype-webapp. Select the archetype that appears in the box below and click Next.
- 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.
- Click your project name from Project Explorer (the tall pane on the left) and press Alt+Enter (it opens your project properties).
- Click Project Facets from the list on left hand side and then click “Convert to faceted form…” from the box on right hand side.
- Check and select “Dynamic Web Module” from facet list.
- Click the Runtimes tab on the right, check Apache Tomcat vX.0 and click Ok at the bottom of the dialog box.
- Select you project from Project Explorer and press Alt+Enter again.
- Select Deployment Assembly from the list on left hand side and click Add button from the box on right hand side.
- Select Java Build Path Entries, next, Maven Dependencies, finish and OK.