Eclipse creates a Maven project

Source: Internet
Author: User

Https://www.cnblogs.com/izecsonLee/p/6156289.html

1. Open Eclipse, right-click new--"Other, if you find Maven project

2. Select Maven Project, display the window to create the MAVEN project, tick, create a simple project

3. Enter the basic information for the MAVEN project as shown in:

4, complete the creation of the MAVEN project, generate the corresponding MAVEN project results, as shown below, some of the structure here is not required by the project, we need to remove:

5, select the project, right-click Properties, go to the property page, select the Maven menu, as shown in:

6, choose Java Version 1.7, and remove the other two, such as:

7, click OK, again back to the project structure, the project structure is relatively clear, in line with the MAVEN project we want to create

8, at this time the results of WebApp is not shown, because at this time we have not configured this project for the Web project, again into the properties configuration, as shown in:

9, click further configuration available ..., as follows:

10. Configure Src/main/webapp, and tick the option to generate Web. XML, as follows:

11. After determining, return to the Maven menu to remove the dynamic Web module check, click OK, as shown below, the WEBAPP directory structure is displayed:

12, at this time also need to configure, Src/main/webapp for the "/" project root directory, as follows:

13, complete the configuration as above, the final completion of the MAVEN WEBAPP project structure as shown:

Part II: Structure of the MAVEN project

A good directory structure makes it easier for developers to understand the project, and also lays a good foundation for future maintenance work. Maven2 provides developers with a default standard catalog template based on the industry's best-known directory structure. The standard directory structure for MAVEN2 is as follows:

Src/main/java Application/library sources
Src/main/resources Application/library Resources
Src/main/filters Resource Filter Files
src/main/assembly Assembly descriptors
Src/main/config Configuration files
Src/main/scripts Application/library scripts
Src/main/webapp WEB Application sources
Src/test/java Test sources
Src/test/resources Test Resources
Src/test/filters Test Resource Filter Files
Src/site Site
LICENSE.txt Project ' s license
NOTICE.txt Notices and attributions required by libraries, the project depends on
README.txt

Project ' s Readme

You can make pom.xml more concise by using the catalog template. Because the MAVEN2 has predefined related actions based on the default directory, no manual intervention is required. Take the resources directory as an example:

    • Src/main/resources, responsible for managing the resources of the project subject. After executing compile with Maven2, all files and subdirectories in this directory are copied to the Target/classes directory, which provides convenience for future packaging.
    • Src/test/resources, responsible for managing the resources of the project test. After executing test-compile with Maven2, all files and subdirectories in this directory are copied to the Target/test-classes directory, ready for subsequent tests.

These actions are in Maven1 and need to be done using <preGoal> or <postGoal> in Maven.xml. Today, you can do this automatically without having to specify it in Pom.xml. The use of resources in both SRC and test, which is easy to build and test, has been the experience of previous generations. By using MAVEN2, this experience has been popularized in the development team.

Eclipse creates a Maven project

Related Article

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.