Create a MAVEN multi-module project with IntelliJ idea

Source: Internet
Author: User

When using MAVEN to manage projects, you often need to create multiple modules, and there is a relationship between the modules that are referenced by each other. For MAVEN dependencies, you also need to specifically create a module to manage dependencies. For example, for a project, you can create a common module to manage the Pojo class, create a server to manage business logic and database operations classes, and create a Web module to organize Web files, such as html,jsp. The following figure is a case project structure for MAVEN multi-module management:

Simple to say the creation process:
1. Create an empty project first: Demo,new the left of the Project dialog box, select Maven Module (the module in idea corresponds to project in Eclipse), as shown in the following illustration:

2.parent Module Creation Select the template to create the project, you can not use the module, Create the project will be more than the SRC directory, manually delete the SRC directory, or select a blank template (to use the template, you need to check the "create from Archetype"), directly create an empty project, operation as shown in the following figure:

3. Right-click->new->module on the name of the project, fill in the Subproject (module) name, select Maven Project, and if it is not a Web module, you can create using a template (that is, do not check "create from archetype"). Common projects need to have SRC directory, src under the main and Test,main under the Java and Resources directory, Java classes are placed in the Java directory.
4. To create a web directory, you need to use the WebApp template, check "Create from archetype", select the Maven-archetype-webapp template, the following figure:

After these steps, A maven-managed multiple-module (subproject) project structure is built. You can put the Maven dependencies you need to use in the Config module (subproject), and other modules can be referenced from config, as shown in the Maven tutorial.
When you open a project, you can use IntelliJ idea to open the main project's Pom.xml file directly to import the MAVEN project, as shown in the following illustration:

Learn maven, recommend a URL:
http://books.sonatype.com/mvnex-book/reference/multimodule.html

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.