Today I want to talk about Maven. It's a very powerful tool. If you know how to use it, you will have the least amount of energy to get the most results. Typically maven helps you manage your projects, including relying on libraries, building processes, etc... But this article will show you how to create a Dynamic Web project (in Eclipse IDE) with Maven.
Pre-Preparation:
Eclipse IDE for Java EE developers
M2E Plugin for Eclipse
Maven
1. File > New (alt+shift+n) > Dynamic Web Project
Enter the name of the project after "project name" (for example: MAVENDWP);
In "Target runtime" Select a We server (I use Apache Tomcat 7.0);
Click on the "Next" button;
Create the directory structure shown (take a closer look at this directory structure.) He is an important detail in creating a Dynamic Web project):
Click on the "Next" button;
Select the Generate Web. XML Deployment descriptor check box;
Click the "Finish" button.
2. Right-click Engineering > Configure > Convert to Maven Project
Select "Packaging" as the war;
Click "Finish" button;
After that, Pom.xml will appear in the structure of the project;
Move all directories under the WebContent folder to Src/main/webapp;
WebContent This file directory can be deleted.
3. Open the project's root directory
Run this command in cmd: mvn eclipse:eclipse-dwtpversion=2.0
This command will generate a configuration about eclipse (. Classpath,. Project, etc.)
Right-click the Src/main/webapp folder: Build Path > Use as Source folder (this point is actual only if Src/main/webapp disappeared from The source folders)
This is the final directory structure of a dynamic Web project created with Maven:
I hope this article is described clearly enough so that you can follow the above description without any problems in building your own project. I will try to answer every question in the comments.
Original link: http://fruzenshtein.com/setup-of-dynamic-web-project-using-maven/
Building Dynamic Web Engineering with MAVEN