一、短路优先
1、基本原则
A->B->C->X(jar)
A->B->X(jar)
这里会选择第2条路径
2、实例
nage依赖于bge,shanji依赖于nage
bge:
<
project
xmlns
=
"
http://maven.apache.org/POM/4.0.0"
;
xmlns:xsi
=
"
http://www.w3.org/2001/XMLSchema-instance"
;
xsi:schemaLocation
=
"
http://maven.apache.org/POM/4.0.0
http://maven.apache.org/xsd/maven-4.0.0.xsd"
;
>
<
modelVersion
>
4.0.0
</
modelVersion
>
<
groupId
>
com.hongxing
</
groupId
>
<
artifactId
>
hongxing
-
bge
</
artifactId
>
<
version
>
0.0.1-SNAPSHOT
</
version
>
<
packaging
>
jar
</
packaging
>
<
name
>
hongxing
-
bge
</
name
>
<
properties
>
<
project.build.sourceEncoding
>
UTF-8
</
project.build.sourceEncoding
>
</
properties
>
<
dependencies
>
<
dependency
>
<
groupId
>
junit
</
groupId
>
<
artifactId
>
junit
</
artifactId
>
<
version
>
3.8.1
</
version
>
<
scope
>
test
</
scope
>
</
dependency
>
<
dependency
>
<
groupId
>
commons-
io
</
groupId
>
<
artifactId
>
commons-
io
</
artifactId
>
<
version
>
2.4
</
version
>
</
dependency
>
</
dependencies
>
</
project
>
nage:
<
project
xmlns
=
"
http://maven.apache.org/POM/4.0.0"
;
xmlns:xsi
=
"
http://www.w3.org/2001/XMLSchema-instance"
;
xsi:schemaLocation
=
"
http://maven.apache.org/POM/4.0.0
http://maven.apache.org/xsd/maven-4.0.0.xsd"
;
>
<
modelVersion
>
4.0.0
</
modelVersion
>
<
groupId
>
com.hongxing
</
groupId
>
<
artifactId
>
hongxing
-
nage
</
artifactId
>
<
version
>
0.0.1-SNAPSHOT
</
version
>
<
packaging
>
jar
</
packaging
>
<
name
>
hongxing
-
nage
</
name
>
<
properties
>
<
project.build.sourceEncoding
>
UTF-8
</
project.build.sourceEncoding
>
</
properties
>
<
dependencies
>
<
dependency
>
<
groupId
>
junit
</
groupId
>
<
artifactId
>
junit
</
artifactId
>
<
version
>
3.8.1
</
version
>
<
scope
>
test
</
scope
>
</
dependency
>
<
dependency
>
<
groupId
>
commons-
io
</
groupId
>
<
artifactId
>
commons-
io
</
artifactId
>
<
version
>
2.0
</
version
>
</
dependency
>
<
dependency
>
<
groupId
>
com.hongxing
</
groupId
>
<
artifactId
>
hongxing
-
bge
</
artifactId
>
<
version
>
0.0.1-SNAPSHOT
</
version
>
</
dependency
>
</
dependencies
>
</
project
>
shanji:
<
project
xmlns
=
"
http://maven.apache.org/POM/4.0.0"
;
xmlns:xsi
=
"
http://www.w3.org/2001/XMLSchema-instance"
;
xsi:schemaLocation
=
"
http://maven.apache.org/POM/4.0.0
http://maven.apache.org/xsd/maven-4.0.0.xsd"
;
>
<
modelVersion
>
4.0.0
</
modelVersion
>
<
groupId
>
com.hongxing
</
groupId
>
<
artifactId
>
hongxing
-
shanji
</
artifactId
>
<
version
>
0.0.1-SNAPSHOT
</
version
>
<
packaging
>
jar
</
packaging
>
<
name
>
hongxing
-
shanji
</
name
>
<
properties
>
<
project.build.sourceEncoding
>
UTF-8
</
project.build.sourceEncoding
>
</
properties
>
<
dependencies
>
<
dependency
>
<
groupId
>
junit
</
groupId
>
<
artifactId
>
junit
</
artifactId
>
<
version
>
3.8.1
</
version
>
<
scope
>
test
</
scope
>
</
dependency
>
<
dependency
>
<
groupId
>
com.hongxing
</
groupId
>
<
artifactId
>
hongxing
-
nage
</
artifactId
>
<
version
>
0.0.1-SNAPSHOT
</
version
>
</
dependency
>
</
dependencies
>
</
project
>
此时shanji依赖于2.0版本
19.png
二 路径相同,先声明先优先
shanji依赖于bge,shanji依赖于nage,bge和nage没有关系
bge:
<
project
xmlns
=
"
http://maven.apache.org/POM/4.0.0"
;
xmlns:xsi
=
"
http://www.w3.org/2001/XMLSchema-instance"
;
xsi:schemaLocation
=
"
http://maven.apache.org/POM/4.0.0
http://maven.apache.org/xsd/maven-4.0.0.xsd"
;
>
<
modelVersion
>
4.0.0
</
modelVersion
>
<
groupId
>
com.hongxing
</
groupId
>
<
artifactId
>
hongxing
-
bge
</
artifactId
>
<
version
>
0.0.1-SNAPSHOT
</
version
>
<
packaging
>
jar
</
packaging
>
<
name
>
hongxing
-
bge
</
name
>
<
properties
>
<
project.build.sourceEncoding
>
UTF-8
</
project.build.sourceEncoding
>
</
properties
>
<
dependencies
>
<
dependency
>
<
groupId
>
junit
</
groupId
>
<
artifactId
>
junit
</
artifactId
>
<
version
>
3.8.1
</
version
>
<
scope
>
test
</
scope
>
</
dependency
>
<
dependency
>
<
groupId
>
commons-
io
</
groupId
>
<
artifactId
>
commons-
io
</
artifactId
>
<
version
>
2.4
</
version
>
</
dependency
>
</
dependencies
>
</
project
>
nage:
<
project
xmlns
=
"
http://maven.apache.org/POM/4.0.0"
;
xmlns:xsi
=
"
http://www.w3.org/2001/XMLSchema-instance"
;
xsi:schemaLocation
=
"
http://maven.apache.org/POM/4.0.0
http://maven.apache.org/xsd/maven-4.0.0.xsd"
;
>
<
modelVersion
>
4.0.0
</
modelVersion
>
<
groupId
>
com.hongxing
</
groupId
>
<
artifactId
>
hongxing
-
nage
</
artifactId
>
<
version
>
0.0.1-SNAPSHOT
</
version
>
<
packaging
>
jar
</
packaging
>
<
name
>
hongxing
-
nage
</
name
>
<
properties
>
<
project.build.sourceEncoding
>
UTF-8
</
project.build.sourceEncoding
>
</
properties
>
<
dependencies
>
<
dependency
>
<
groupId
>
junit
</
groupId
>
<
artifactId
>
junit
</
artifactId
>
<
version
>
3.8.1
</
version
>
<
scope
>
test
</
scope
>
</
dependency
>
<
dependency
>
<
groupId
>
commons-
io
</
groupId
>
<
artifactId
>
commons-
io
</
artifactId
>
<
version
>
2.0
</
version
>
</
dependency
>
</
dependencies
>
</
project
>
shanji:
<
project
xmlns
=
"
http://maven.apache.org/POM/4.0.0"
;
xmlns:xsi
=
"
http://www.w3.org/2001/XMLSchema-instance"
;
xsi:schemaLocation
=
"
http://maven.apache.org/POM/4.0.0
http://maven.apache.org/xsd/maven-4.0.0.xsd"
;
>
<
modelVersion
>
4.0.0
</
modelVersion
>
<
groupId
>
com.hongxing
</
groupId
>
<
artifactId
>
hongxing
-
shanji
</
artifactId
>
<
version
>
0.0.1-SNAPSHOT
</
version
>
<
packaging
>
jar
</
packaging
>
<
name
>
hongxing
-
shanji
</
name
>
<
properties
>
<
project.build.sourceEncoding
>
UTF-8
</
project.build.sourceEncoding
>
</
properties
>
<
dependencies
>
<
dependency
>
<
groupId
>
junit
</
groupId
>
<
artifactId
>
junit
</
artifactId
>
<
version
>
3.8.1
</
version
>
<
scope
>
test
</
scope
>
</
dependency
>
<
dependency
>
<
groupId
>
com.hongxing
</
groupId
>
<
artifactId
>
hongxing
-
bge
</
artifactId
>
<
version
>
0.0.1-SNAPSHOT
</
version
>
</
dependency
>
<
dependency
>
<
groupId
>
com.hongxing
</
groupId
>
<
artifactId
>
hongxing
-
nage
</
artifactId
>
<
version
>
0.0.1-SNAPSHOT
</
version
>
</
dependency
>
</
dependencies
>
</
project
>
此时shanji依赖于2.4版本