Ошибка: -
Buckets: Исключение в потоке "main" java.lang.NoSuchMethodError: com.google.api.services.storage.Storage $ Buckets $ List.setUserProject (Ljava / lang/ String;) Lcom / Google / API / услуги / хранение / Хранение $ Ковши $ Список;на com.google.cloud.storage.spi.v1.HttpStorageRpc.list (HttpStorageRpc.java:311) на com.google.cloud.storage.StorageImpl $ 6.call (StorageImpl.java:272) на com.google.cloud.storage.StorageImpl $ 6.call (StorageImpl.java:269) на com.google.api.gax.retry.DirectRetringExecutor.submit (DirectRetringExecutor.java:89) на com.google.cloud.RetryHelper.run (RetryHelper.java:74) на com.google.cloud.RetryHelper.runWithRetries (RetryHelper.java:51) на com.google.cloud.storage.StorageImpl.listBuckets (StorageImpl.java:268) на com.google.cloud.storage.StorageImpl.list (StorageImpl.java:257) в com.example.dialogflow.DetectIntentTexts.main (DetectIntentTexts.java:103)
Код: -
public static void main(String[] args) throws Exception {
// You can specify a credential file by providing a path to GoogleCredentials.
// Otherwise credentials are read from the GOOGLE_APPLICATION_CREDENTIALS
// environment variable.
GoogleCredentials credentials = GoogleCredentials
.fromStream(new FileInputStream("/home/agile/karan/ElysiotCredentials/Elysiot-9cxxxxxxxxxx.json"))
.createScoped(Lists.newArrayList("https://www.googleapis.com/auth/cloud-platform"));
Storage storage = StorageOptions.newBuilder().setCredentials(credentials).build().getService();
System.out.println("Buckets:");
Page<Bucket> buckets = storage.list();
for (Bucket bucket : buckets.iterateAll()) {
System.out.println(bucket.toString());
}
}