升级Apache Beam后google-api-services-storage的getSoftDeletePolicy()问题
临时解决Apache Beam 2.67.0与google-api-services-storage兼容性问题的方案
针对你升级Apache Beam到2.67.0时遇到的google-api-services-storage库getSoftDeletePolicy()方法缺失问题,以下是几个可行的临时解决方案:
1. 添加Google Maven仓库拉取未发布版本
Google官方维护了专属Maven仓库,包含部分尚未同步到中央仓的库版本。在你的pom.xml中添加该仓库配置,即可拉取v1-rev20230822-2.0.0版本:
<repositories> <repository> <id>google-maven-central</id> <url>https://maven.google.com</url> </repository> </repositories> <dependencies> <dependency> <groupId>com.google.apis</groupId> <artifactId>google-api-services-storage</artifactId> <version>v1-rev20230822-2.0.0</version> </dependency> </dependencies>
2. 排除Beam自带的冲突依赖
Apache Beam可能自带旧版本的google-api-services-storage,引发依赖冲突。在引入Beam依赖时显式排除该库,再手动引入所需版本:
<dependency> <groupId>org.apache.beam</groupId> <artifactId>beam-sdks-java-io-google-cloud-platform</artifactId> <version>2.67.0</version> <exclusions> <exclusion> <groupId>com.google.apis</groupId> <artifactId>google-api-services-storage</artifactId> </exclusion> </exclusions> </dependency> <!-- 手动引入兼容版本 --> <dependency> <groupId>com.google.apis</groupId> <artifactId>google-api-services-storage</artifactId> <version>v1-rev20230822-2.0.0</version> </dependency>
注意:此方法需配合Google Maven仓库使用,确保能拉取到指定版本。
3. 临时降级Beam到过渡版本
如果当前业务对Beam 2.67.0的新特性没有强依赖,可临时降级到Beam 2.60.x系列版本(如2.60.0)。这些版本尚未依赖SoftDeletePolicy相关方法,能规避兼容性问题,等目标google-api-services-storage版本发布到中央仓后再升级到2.67.0。
4. 本地构建指定版本的Jar包
从Google的GitHub仓库拉取对应版本代码,本地构建Jar包并安装到本地Maven仓库:
- 克隆仓库:
git clone https://github.com/googleapis/google-api-java-client-services.git - 切换到对应
v1-rev20230822-2.0.0的提交记录 - 进入
storage/v1目录,执行mvn clean install,将构建好的Jar包安装到本地仓库 - 项目中直接依赖该版本即可
内容的提问来源于stack exchange,提问作者Optimizer
相关产品推荐
相关产品推荐

