【发布时间】:2017-09-11 00:56:44
【问题描述】:
这是我读取云存储文件的方法
public static String getStringObject(String bucketName, String fileName) throws Exception{
BlobId blobId = BlobId.of(bucketName, fileName);
byte[] content = storage.readAllBytes(blobId);
String contentString = new String(content, UTF_8);
return contentString;
}
当我从我的开发环境中调用此方法以从存储桶中读取文件时,它工作正常。但是,当我在运行 spark 作业时从 Dataproc 集群调用此方法时,会引发以下错误。
Exception in thread "main" java.lang.NoSuchMethodError: com.google.common.util.concurrent.MoreExecutors.directExecutor()Ljava/util/concurrent/Executor;
at com.google.api.gax.retrying.BasicRetryingFuture.<init>(BasicRetryingFuture.java:77)
at com.google.api.gax.retrying.DirectRetryingExecutor.createFuture(DirectRetryingExecutor.java:75)
at com.google.cloud.RetryHelper.runWithRetries(RetryHelper.java:53)
at com.google.cloud.storage.StorageImpl.readAllBytes(StorageImpl.java:460)`
这是我的 maven pom.xml 的一部分
<dependency>
<groupId>com.google.cloud</groupId>
<artifactId>google-cloud-storage</artifactId>
<version>1.4.0</version>
</dependency>
<dependency>
<groupId>com.google.guava</groupId>
<artifactId>guava</artifactId>
<version>19.0</version>
</dependency>
<dependency>
<groupId>com.google.api-client</groupId>
<artifactId>google-api-client</artifactId>
<version>1.22.0</version>
</dependency>
我在这里做错了什么?
【问题讨论】:
标签: java google-cloud-storage google-api-client nosuchmethoderror google-cloud-dataproc