MAVEN's Learning Data collection-(iii) building Web projects with Maven

Source: Internet
Author: User

    1. New MAVEN Project
      1. File-new-other
      2. Select Maven Project Click Next
      3. Leave the default and click Next
      4. Select archetype for web App click Next
      5. Enter some necessary information click Finish
      6. Project structure such as
    2. Configuration Items
      1. On the project, right-click Add Source Folder
      2. Modifying the Build Path configuration
      3. Convert a project to a dynamic WEB project
      4. 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.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.