gpt4 book ai didi

java - 具有 google-cloud-core-grpc 依赖性的 Java 应用程序中的 Maven 冲突

转载 作者:塔克拉玛干 更新时间:2023-11-03 04:21:55 26 4
gpt4 key购买 nike

(I've also raised a GitHub issue for this - https://github.com/googleapis/google-cloud-java/issues/4095)

我有以下 2 个 Apache Beam 依赖项的最新版本:

依赖项 1 - google-cloud-dataflow-java-sdk-all

(Apache Beam 的发行版旨在简化 Apache Beam 在 Google 云数据流服务上的使用 - https://mvnrepository.com/artifact/com.google.cloud.dataflow/google-cloud-dataflow-java-sdk-all)

<dependency>
<groupId>com.google.cloud.dataflow</groupId>
<artifactId>google-cloud-dataflow-java-sdk-all</artifactId>
<version>2.5.0</version>
</dependency>

依赖项 2 - beam-runners-google-cloud-dataflow-java

(我猜这允许在 Google Cloud Dataflow 中实际运行 Beam 管道)

https://mvnrepository.com/artifact/org.apache.beam/beam-runners-google-cloud-dataflow-java

<dependency>
<groupId>org.apache.beam</groupId>
<artifactId>beam-runners-google-cloud-dataflow-java</artifactId>
<version>2.8.0</version>
</dependency>

Maven 安装可以很好地处理这两个依赖项。我需要添加以下(第 3 个)依赖项以独立订阅 Apache Beam 管道之外的 Google Cloud 发布/订阅:

google-cloud-pubsub

https://mvnrepository.com/artifact/com.google.cloud/google-cloud-pubsub

<dependency>
<groupId>com.google.cloud</groupId>
<artifactId>google-cloud-pubsub</artifactId>
<version>1.53.0</version>
</dependency>

(这是最新版本)。添加后,我在执行 mvn clean install 后遇到以下冲突:

Could not resolve version conflict among [com.google.cloud:google-cloud-pubsub:jar:1.53.0 -> com.google.cloud:google-cloud-core-grpc:jar:1.53.0 -> io.grpc:grpc-protobuf:jar:1.16.1 -> io.grpc:grpc-core:jar:1.16.1, com.google.cloud:google-cloud-pubsub:jar:1.53.0 -> com.google.cloud:google-cloud-core-grpc:jar:1.53.0 -> io.grpc:grpc-protobuf:jar:1.16.1 -> io.grpc:grpc-protobuf-lite:jar:1.16.1 -> io.grpc:grpc-core:jar:1.16.1, com.google.cloud:google-cloud-pubsub:jar:1.53.0 -> io.grpc:grpc-netty-shaded:jar:1.16.1 -> io.grpc:grpc-core:jar:[1.16.1,1.16.1], com.google.cloud:google-cloud-pubsub:jar:1.53.0 -> io.grpc:grpc-stub:jar:1.16.1 -> io.grpc:grpc-core:jar:1.16.1, com.google.cloud:google-cloud-pubsub:jar:1.53.0 -> io.grpc:grpc-auth:jar:1.16.1 -> io.grpc:grpc-core:jar:[1.16.1,1.16.1], com.google.cloud.dataflow:google-cloud-dataflow-java-sdk-all:jar:2.5.0 -> org.apache.beam:beam-sdks-java-io-google-cloud-platform:jar:2.5.0 -> io.grpc:grpc-core:jar:1.2.0, com.google.cloud.dataflow:google-cloud-dataflow-java-sdk-all:jar:2.5.0 -> org.apache.beam:beam-sdks-java-io-google-cloud-platform:jar:2.5.0 -> io.grpc:grpc-netty:jar:1.2.0 -> io.grpc:grpc-core:jar:[1.2.0,1.2.0], com.google.cloud.dataflow:google-cloud-dataflow-java-sdk-all:jar:2.5.0 -> org.apache.beam:beam-sdks-java-io-google-cloud-platform:jar:2.5.0 -> com.google.cloud.bigtable:bigtable-protos:jar:1.0.0-pre3 -> io.grpc:grpc-core:jar:1.5.0, com.google.cloud.dataflow:google-cloud-dataflow-java-sdk-all:jar:2.5.0 -> org.apache.beam:beam-sdks-java-io-google-cloud-platform:jar:2.5.0 -> com.google.cloud.bigtable:bigtable-client-core:jar:1.0.0 -> io.grpc:grpc-core:jar:1.7.0, com.google.cloud.dataflow:google-cloud-dataflow-java-sdk-all:jar:2.5.0 -> org.apache.beam:beam-sdks-java-io-google-cloud-platform:jar:2.5.0 -> com.google.cloud.bigtable:bigtable-client-core:jar:1.0.0 -> io.opencensus:opencensus-contrib-grpc-util:jar:0.7.0 -> io.grpc:grpc-core:jar:1.6.1, com.google.cloud.dataflow:google-cloud-dataflow-java-sdk-all:jar:2.5.0 -> org.apache.beam:beam-sdks-java-io-google-cloud-platform:jar:2.5.0 -> io.grpc:grpc-all:jar:1.2.0 -> io.grpc:grpc-core:jar:[1.2.0,1.2.0], com.google.cloud.dataflow:google-cloud-dataflow-java-sdk-all:jar:2.5.0 -> org.apache.beam:beam-sdks-java-io-google-cloud-platform:jar:2.5.0 -> io.grpc:grpc-all:jar:1.2.0 -> io.grpc:grpc-okhttp:jar:1.2.0 -> io.grpc:grpc-core:jar:[1.2.0,1.2.0], com.google.cloud.dataflow:google-cloud-dataflow-java-sdk-all:jar:2.5.0 -> org.apache.beam:beam-sdks-java-io-google-cloud-platform:jar:2.5.0 -> io.grpc:grpc-all:jar:1.2.0 -> io.grpc:grpc-protobuf-nano:jar:1.2.0 -> io.grpc:grpc-core:jar:1.2.0

如果我删除 Apache Beam 依赖项并保留 google-cloud-pubsub 依赖项,我不会遇到任何 Maven 安装冲突。

有一个单独的 Google“BOM”( Material list )依赖项管理器,它应该管理 Google Cloud 依赖项的子依赖项,但这并不能解决我的冲突:

  <dependencyManagement>
<dependencies>
<dependency>
<groupId>com.google.cloud</groupId>
<artifactId>google-cloud-bom</artifactId>
<version>0.71.0-alpha</version>
<type>pom</type>
<scope>import</scope>
</dependency>
</dependencies>
</dependencyManagement>

我按照这个问题的答案 -

How do I resolve a dependency conflict in Maven?

我发现了


  • com.google.cloud:google-cloud-pubsub:jar:1.53.0

具有子依赖性:

io.grpc:grpc-core:jar:1.16.1


  • com.google.cloud.dataflow:google-cloud-dataflow-java-sdk-all:jar:2.5.0

对以下的各种版本具有子依赖性:

io.grpc:grpc-core:jar


(GRPC是一个高性能、开源的通用RPC框架)

如果我将 io.grpc:grpc-core:jar:1.6.1 添加为我的 POM 文件的显式依赖项,它不会“固定”依赖项,因为它仍然被拉入作为 com.google.cloud.dataflow:google-cloud-dataflow-java-sdk-all:jar:2.5.0 的子依赖项。

在以下 GitHub 问题上,garrettjonesgoogle 于 2 月 21 日确认 google-cloud-bom 没有固定 io.grpc:grpc-core 的版本:

https://github.com/googleapis/google-cloud-java/issues/2890

似乎 Apache Beam 依赖项在内部管理着不同版本的 io.grpc:grpc-core:jar,但这与 Google pub/sub 依赖项使用的(一致的)版本冲突.

有什么办法可以解决这个问题吗?我可以使用 Maven 以某种方式隔 ionic 依赖项吗?

最佳答案

我能够通过购买从 google-cloud-pubsub Artifact 中排除 grpc-core 来解决这个问题。之后它被合并到依赖树中,与 beam-runners-google-cloud-dataflow-java 的依赖相同的版本 1.13.1

这是对我有用的 pom.xml 的摘录。

<dependencies>
<dependency>
<groupId>com.google.cloud</groupId>
<artifactId>google-cloud-pubsub</artifactId>
<version>1.53.0</version>
<exclusions>
<exclusion>
<groupId>io.grpc</groupId>
<artifactId>grpc-core</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.apache.beam</groupId>
<artifactId>beam-runners-google-cloud-dataflow-java</artifactId>
<version>2.8.0</version>
</dependency>
</dependencies>

关于java - 具有 google-cloud-core-grpc 依赖性的 Java 应用程序中的 Maven 冲突,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53424272/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com