Notes
Search…
Notes
Introduce
Go
Grammar
System Library
Concurrency in Go
The Go Memory Model
Rust
The Rust Programming Language
Rust by Example
JAVA
Preface
Grammar
Class Libraries
Concurrency
JVM
Web Container
Spring
Tuning
Computer Science
Computer Organization
Algorithm
Network Protocol
Operating System
Design Patterns
Microservice
Distributed System
database
InfluxDB
MySQL
Redis
Elasticsearch
HBase
Kafka
ZooKeeper
MongoDB
Reading
RocketMQ
演说之禅
Other
v2ray
Kubernetes
Git
Maven
Anaconda And Conda
Fuck! Shit!
Open source contribution
Powered By
GitBook
Maven
可选依赖于依赖排除
Optional 和 Exclusions 都是用来排除jar包依赖使用的。
Project-X 依赖 Project-A,Project-A 依赖 Project-B。
Optional
1
<!-- Project-A 的 pom 文件 -->
2
<
project
>
3
...
4
<
dependencies
>
5
<
dependency
>
6
<
groupId
>
sample.ProjectB
</
groupId
>
7
<
artifactId
>
Project-B
</
artifactId
>
8
<
version
>
1.0
</
version
>
9
<
scope
>
compile
</
scope
>
10
<
optional
>
true
</
optional
>
11
</
dependency
>
12
</
dependencies
>
13
</
project
>
Copied!
如上 X 依赖 A,A 依赖 B 用的
<optional>true</optional>
,这时 B 只能在 A 中使用,而不会主动传递到 X 中,X 需要主动引用 B 才有 B 的依赖。
Exclusions
1
<!-- Project-X 的 pom 文件 -->
2
<
dependencies
>
3
<
dependency
>
4
<
groupId
>
sample.ProjectA
</
groupId
>
5
<
artifactId
>
Project-A
</
artifactId
>
6
<
version
>
1.0
</
version
>
7
<
scope
>
compile
</
scope
>
8
<
exclusions
>
9
<
exclusion
>
10
<
groupId
>
sample.ProjectB
</
groupId
>
11
<
artifactId
>
Project-B
</
artifactId
>
12
</
exclusion
>
13
</
exclusions
>
14
</
dependency
>
15
</
dependencies
>
Copied!
如果 A 不用
<optional>true</optional>
引用 B,则会传递到 X 中,X 如果不需要 B 则需要主动排除 A 传递过来的 B。
http://maven.apache.org/guides/introduction/introduction-to-optional-and-excludes-dependencies.html
https://www.jianshu.com/p/6eee9191f2ab
Other - Previous
Git
Next - Other
Anaconda And Conda
Last modified
3yr ago
Copy link
Contents
可选依赖于依赖排除
Optional
Exclusions