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.
3. If you don’t have a configured Eclipse Server, add one now. Here we will register a new Tomcat 7 server. Open the Servers view, right click -> New -> Server.
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>
Thanks a lot !!!
Proper explanation with IDE screen shots.
6. step
if there is no maven dependencies in list – how to add they there?
Try skipping that step and see if it works. I think you don’t need that step in newer version of Eclipse/m2e.
you can add the dependency to the maven dependency list as long as you know the group ID, artifact ID and version~ These information can always be found in maven repository.
In my case, I don’t have spring-mvc-jpa-archetype. So I search it online. Here is what I found
org.fluttercode.knappsack
spring-mvc-jpa-archetype
1.1
BTW just leave the repository URL blank.