- New MAVEN Project
- File-new-other
- Select Maven Project Click Next
- Leave the default and click Next
- Select archetype for web App click Next
- Enter some necessary information click Finish
- Project structure such as
- Configuration Items
- On the project, right-click Add Source Folder
- Modifying the Build Path configuration
- Convert a project to a dynamic WEB project
- Set deployment assembly Web Deployment Assembly
From the Internet to find some information, only to understand (that is how to operate it), how to use MAVEN to build a Web project, to find a document, mainly learned from here:
: Use Eclipse to build a MAVEN Web project. docx
Now you re-operate: (using the Eclipse Java EE Edition ps:eclipse-jee-indigo-sr1-win32, has installed the M2eclipse plugin)
1. Create a new MAVEN project
1.1 File, New and other
1.2 Select Maven Project, click Next
1.3 Leave the default, click Next
1.4 Select archetype for Web app, click Next
1.5 Enter some necessary information and click Finish
1.6 Project structure such as:
2. Configuration Items
Now start modifying some configurations
2.1 Right-click on project to add source Folder
MAVEN projects have some conventions: Src/main/java, Src/main/resources, Src/test/java, src/test/resources. Then, add these folders:
Enter the name of the source Folder
After creating the directory structure:
2.2 Modifying the Build Path configuration
On the project, right-click, select Build path->configure build path
Select the source tag and the 4 source folder will be displayed, modifying their OutPut folder:
Double-click the output folder for each of the folders to select the path
Src/main/java,src/main/resources, choose target/classes;
Src/test/java, src/test/resources, choose target/test-classes;
After the modification is complete as shown:
To modify the JDK version: Select the libraries tag, select the JRE library, click the Edit button
Select the system default is OK, click the Finish button:
Finally, click OK:
Upon completion, the project structure is as follows:
2.3 Convert a project to dynamic WEB project
Right-click on the project and select Properties:
Select Project Facets on the left and click on the "Convert faceted from" link on the right:
Modify Java as the JDK for your current project, add the dynamic Web Module, and then click the further Configuration available link:
To modify content directory to Src/main/webapp, click OK:
In one click OK, complete the operation:
2.4 Setting up Deployment Assemblies (Web Deployment Assembly)
Right-click on the project, select Properties, select Deployment Assembly on the left
The list here is the path to the file publication when the project is deployed.
1, we delete the two items of test, because tests are used for testing and do not need to be deployed.
2, set the Maven jar package to be published under Lib.
ADD, Java Build Path Entries, Maven Dependencies, Finish
Setup Complete
Click OK
When you are finished, the project structure looks like this:
In this way, a Web project built with Maven is done, and in the next blog we will write a simple user-logged servlet test.