如何在gcp中获得bucket中的对象列表?

slmsl1lt  于 2021-05-27  发布在  Spark
关注(0)|答案(0)|浏览(315)

我试图获取gcp bucket中的对象列表,但遇到以下错误:,

java.lang.NoSuchMethodError: com.google.common.io.Files.asCharSource(Ljava/io/File;Ljava/nio/charset/Charset;)Lcom/google/common/io/CharSource;

at com.google.cloud.ServiceOptions.getActiveGoogleCloudConfig(ServiceOptions.java:395)
at com.google.cloud.ServiceOptions.getGoogleCloudProjectId(ServiceOptions.java:413)
at com.google.cloud.ServiceOptions.getDefaultProjectId(ServiceOptions.java:384)
at com.google.cloud.ServiceOptions.getDefaultProject(ServiceOptions.java:356)
at com.google.cloud.ServiceOptions.<init>(ServiceOptions.java:302)
at com.google.cloud.storage.StorageOptions.<init>(StorageOptions.java:83)
at com.google.cloud.storage.StorageOptions.<init>(StorageOptions.java:31)
at com.google.cloud.storage.StorageOptions$Builder.build(StorageOptions.java:78)
at com.google.cloud.storage.StorageOptions.getDefaultInstance(StorageOptions.java:126)
at com.walmart.ei.TestUtils.callingGcpBucket(TestUtils.scala:18)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:50)
at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:47)
at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:17)
at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:325)
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:78)
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:57)
at org.junit.runners.ParentRunner$3.run(ParentRunner.java:290)
at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:71)
at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:288)
at org.junit.runners.ParentRunner.access$000(ParentRunner.java:58)
at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:268)
at org.junit.runners.ParentRunner.run(ParentRunner.java:363)
at org.junit.runner.JUnitCore.run(JUnitCore.java:137)
at com.intellij.junit4.JUnit4IdeaTestRunner.startRunnerWithArgs(JUnit4IdeaTestRunner.java:68)
at com.intellij.rt.junit.IdeaTestRunner$Repeater.startRunnerWithArgs(IdeaTestRunner.java:33)
at com.intellij.rt.junit.JUnitStarter.prepareStreamsAndStart(JUnitStarter.java:230)
at com.intellij.rt.junit.JUnitStarter.main(JUnitStarter.java:58)

这是我的代码得到的名单,我不知道到底是什么错误。

@Test
  def callingGcpBucket() : Unit = {

val storage = StorageOptions.getDefaultInstance.getService
val bucket = storage.get("wmt-omni-datalake-dev-ei-dqa-audit-dev")

println(bucket)

 }

暂无答案!

目前还没有任何答案,快来回答吧!

相关问题