Original blog from: http://blog.csdn.net/liutengteng130/article/details/47000069 thanks!
Suppose a-->c b-->a ==> b-->c ,a relies on C is directly dependent,B depends on a is directly dependent on ,B relies on C as a transitive dependency.
Phenomenon One
For example:a-->log1.0 b-->log2.0 c-->a,b Then we look at dependencies:
User-core relies on log4j 1.2.17
<dependency>
<groupId>log4j</groupId>
<artifactId>log4j</artifactId>
<version>1.2.17</version>
</dependency>
the User-log package relies on log4j 1.2.9
<dependency>
<groupId>log4j</groupId>
<artifactId>log4j</artifactId>
<version>1.2.9</version>
</dependency>
User-service relies on User-core and also relies on user-log
You can see that the version number of the log4j that User-service relies on 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 User-core first, then rely on user-log. Here 's a look at the Commons-logging.jar version number:
User-core inside the commons-logging version number is 1.0.4
User-log inside the commons-logging version number is 1.1.1
User-service inside The commons-logging version number is 1.1.1
According to the first,User-service inside the jar version should be 1.0.4, now why is 1.1.1 ?
Let us analyze:
User-core is dependent on dbunit, and Commons-logging.jar is referenced as a dependency.
User-log 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.
Turn "maven Combat (vii)---delivery dependencies