Dependencymanagement Unified Multi-module dependent version

Source: Internet
Author: User
One, Dependencymanagement Unified multi-module dependent version

If your project has multiple sub-modules, and each module needs to introduce dependencies, but for the project to work correctly, you must have all of the subproject (sub-projects referred to as sub-modules) use a consolidated version of the dependencies to ensure that the same results are tested and published. So how to ensure that the version between the modules is consistent.

Maven uses Dependencymanagement to unify the dependency version of the module.

In the parent project's Pom file, we will use the dependencymanagement element. It manages the version of the jar package so that the subproject references a list version number that is dependent instead of being displayed. Maven walks up the parent-child hierarchy until it finds a project that has a dependencymanagement element, and then it uses the version number specified in the Dependencymanagement element.

For example: Pom.xml in the top level

[HTML] View plain copy <dependencyManagement> <dependencies> <dependency>                 <groupId>javax</groupId> <artifactId>javaee-api</artifactId>     <version>${javaee-api.version}</version> </dependency> </dependencies> </dependencyManagement>
Dependency on the use of parent pom.xml in child modules:

[html]  View Plain  copy <!--inherit parent class-->     <parent>         <artifactId> Parent artifactid</artifactid>          <groupId> Father groupid</groupid>         <version > Parent version</version>         <relativePath> Parent Pom.xml relative path </relativePath>     </parent>     <!--dependency-->      <dependencies>         <dependency>              <groupId>javax</groupId>              <artifactid>javaee-api</artifactid >       </dependency>     </dependencies>    

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.