Maven Combat (vii)---delivery dependencies

Source: Internet
Author: User

         AssumptionsA-->c B-->a ==> b-->c,Arelies onCis directly dependent,Brelies onAis directly dependent,Brelies onCis a transitive dependency.

Phenomenon One

As an example: A -->log1.0 b-->log2.0 c-->a,b so let's look at dependencies:

User-core relies on log4j 1.2.17

<dependency><groupid>log4j</groupid><artifactid>log4j</artifactid><version >1.2.17</version></dependency>
 

User-log packages depend on log4j 1.2.9

<dependency><groupid>log4j</groupid><artifactid>log4j</artifactid><version >1.2.9</version></dependency>

User-service relies on User-core, also relies on User-log


can see User-service dependent on the log4j The version number is 1.2.9 . Because relying on the log first , after relying on the core,user-service dependency log4j is equivalent to indirect dependency. Therefore, when there is an indirect dependency, which one depends on, it depends on which package is indirectly dependent.

Summary: Indirect dependency, if the level is the same, depends on the first reference dependency.

Phenomenon II

rely on the first User-core, again depends on the User-log. See below Commons-logging.jar The version number:


User-core inside the commons-logging The version number is 1.0.4

User-log inside the commons-logging The version number is 1.1.1

User-service inside commons-logging The version number is 1.1.1

according to the first type, User-service inside the Jar The version should be 1.0.4 , now why is 1.1.1 it?

Let us analyze:



User-core the inside depends on Dbunit , while Commons-logging.jar is referenced as a dependency

User-log the inside is directly quoted Commons-logging.jar

So they are on different dependency trees, and the shallower the depth is the preferred choice.

Summary

1. on the project's dependency tree, the shallower the depth, the more limited the choice.

2. If two dependent packages are on the same level as the dependent tree, who is selected before.

In summary, avoid the best practices that cause version problems to occur when passing dependencies. In general, if the project relies directly on multiple modules of a framework, it is best to declare these dependencies all.

Copyright NOTICE: This article for Bo Master original article, without Bo Master permission not reproduced.

Maven Combat (vii)---delivery 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.