为什么google-api-client依赖于guava-jdk5?

时间:2017-11-05 20:18:49

标签: java maven google-api google-api-client google-api-java-client

我在Maven依赖项中依赖于Guava:

<dependency>
    <groupId>com.google.guava</groupId>
    <artifactId>guava</artifactId>
    <version>23.3-jre</version>
</dependency>

我的依赖项中也依赖于Google API客户端:

<dependency>
    <groupId>com.google.api-client</groupId>
    <artifactId>google-api-client</artifactId>
    <version>1.23.0</version>
</dependency>

但由于一些奇怪的原因,这具有以下依赖性:

<dependency>
  <groupId>com.google.guava</groupId>
  <artifactId>guava-jdk5</artifactId>
</dependency>

现在我的WAR结束了两个Guava JAR:

  • 番石榴-23.3-jre.jar
  • 番石榴jdk5-17.0.jar

这会产生一些问题,因为在使用guava-jdk5-17.0.jar编译代码时,运行时更喜欢guava-23.3-jre.jar

为什么Google API客户端依赖Guava for JDK5?拥有两个版本不会更有意义,例如:

  • google-api-client取决于常规番石榴,最好是版本23.3(截至当前)
  • google-api-client-jdk5依赖于Guava for JDK5

1 个答案:

答案 0 :(得分:6)

https://github.com/google/google-api-java-client/issues/903。以下解决办法应该是可能的:

    <dependency>
        <groupId>com.google.api-client</groupId>
        <artifactId>google-api-client</artifactId>
        <exclusions>
            <exclusion>
                <groupId>com.google.guava</groupId>
                <artifactId>guava-jdk5</artifactId>
            </exclusion>
        </exclusions>
    </dependency>