This quick tutorial will show you how to create a Maven project with a Dynamic Web Module facet. It uses m2e to generate the Maven project.
1. Run Eclipse and switch to the Java EE perspective.
2. Create a new Maven project. Pick the spring-mvc-jpa-archetype to get a fully configured Spring 3 MVC application.
4. Hit next and enter the Tomcat installation directory.
When you hit next, notice you will not see any available resources that you can move to the server.
We still have to configure our new Maven project to become a Dynamic Web Module. This is our next step. Hit Finish to complete the new Server setup.
5. Now right click on the project and click Properties. Go to Project Facets.
Click on “Convert to faceted form” and pick “Dynamic Web Module” version 2.5. Picking version 2.5 makes it compatible with older web containers. Click “Further configuration available”, enter “srcmainwebapp” for the content directory, and hit OK.
6. Now to make the Maven dependencies available to the Dynamic Web Module, go to Project Properties again and click on Deployment Assembly. Click Add… and pick “Java Build Path Entries”. Hit next and pick Maven Dependencies.
7. Our project is now fully configured. To test, go to the Servers view, right click on the Tomcat Server and hit “Add and Remove…”. Pick mavenweb from the available resources and add it to the Server.
Start the server and go to http://localhost:8080/mavenweb. You should see
Now you have a Maven project fully configured as a Dynamic Web Module.
If you want to create the Maven project using mvn eclipse:eclipse, you have to configure the wtpversion.
<plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-eclipse-plugin</artifactId> <version>2.8</version> <configuration> <wtpversion>2.0</wtpversion> </configuration> </plugin>