【发布时间】:2018-03-30 05:50:48
【问题描述】:
我知道有很多关于使用 maven 排除依赖项的问题。遗憾的是,我找不到适合我情况的答案,因为我不想用我自己的另一个版本替换排除的库。
让我描述一下确切的问题。
我们在 REST 端点文档中使用 swagger。因此,swagger 在 pom 文件中被声明为依赖项。
<dependency>
<groupId>io.springfox</groupId>
<artifactId>springfox-swagger2</artifactId>
</dependency>
Swagger 本身将 google guava 声明为编译依赖,如下所示:
springfox-swagger2
-> springfox-spi
-> springfox-core
-> guava
现在 guava 在我们的项目中可用并且人们开始使用它,我们希望阻止这种情况。我试图从这样的招摇依赖中排除番石榴:
<dependency>
<groupId>io.springfox</groupId>
<artifactId>springfox-swagger-ui</artifactId>
<exclusions>
<exclusion>
<groupId>com.google.guava</groupId>
<artifactId>guava</artifactId>
</exclusion>
</exclusions>
</dependency>
现在 Eclipse 告诉我,swagger 正在从 guava 中引用一个不在类路径上的库。难道不能告诉maven我不想在我的项目中有传递依赖,而是让swagger尽可能地使用它。
【问题讨论】: