Eclipse creates MAVEN multi-module engineering

Source: Internet
Author: User

First, create the parent project

"New", "Maven Project"

Select "Create a simple project ..." in the pop-up screen

Second, create sub-projects

Select the parent project you just built, and in the pop-up menu, click "New" and "other".Maven Module】

Third, optimize the configuration

The subproject created by the previous step pom.xml has a node in it, parent so he can inherit information about the parent project.

In a subproject pom.xml , the child project is the groupId same as the version Normal and parent project, so you can delete the two parameters of the project, which automatically inherits the value of the parent item.

Similarly, if any of the other properties, all child items are the same, you can move up to the parent project setting, and the subproject does not need to be set repeatedly. For example, <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> you can set only one time in a parent project.

In addition to this situation, there is a situation, that is, dependencies and plug-ins. dependencies and plug-ins are such that a dependency or plug-in may be used by most sub-projects, but there may be some sub-projects that do not need to be used, so it is not appropriate to simply inherit in the way described above.

Manen offers dependencyManagement and pluginManagement two labels. Using these two tags, you can uniformly manage dependencies and plug-in configuration parameters, such as version numbers, in the parent project. In sub-projects, only the dependencies and plug-ins that need to be used are listed groupId artifactId , and other information is automatically retrieved from the parent project management information.

example, parent project:

<dependencymanagement>  <Dependencies>    <Dependency>        <groupId>Junit</groupId>        <Artifactid>Junit</Artifactid>        <version>${junit.version}</version>        <Scope>Test</Scope>    </Dependency>    <Dependency>        <groupId>Org.slf4j</groupId>        <Artifactid>Slf4j-log4j12</Artifactid>        <version>1.7.5</version>        <Scope>Test</Scope>    </Dependency>    <Dependency>        <groupId>Org.slf4j</groupId>        <Artifactid>Slf4j-api</Artifactid>        <version>1.7.5</version>    </Dependency>     </Dependencies></dependencymanagement>

Sub-project:

<Dependencies>  <Dependency>    <groupId>Junit</groupId>    <Artifactid>Junit</Artifactid>  </Dependency></Dependencies>

Reference:

http://ju.outofmemory.cn/entry/75620

Http://www.cnblogs.com/qiyebao/p/5300539.html

Eclipse creates MAVEN multi-module engineering

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.