如何解析com.google.cloud.Service的类文件 [英] How to resolve class file for com.google.cloud.Service not found

查看:62
本文介绍了如何解析com.google.cloud.Service的类文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试将JSON数据上传到gcs.由于我以前没有使用过Google Cloud,因此我开始将随机String上载到gcs,但是在创建存储服务对象时却陷入了起步阶段

I am Trying to upload JSON data to gcs. As I did not use google cloud previously I started with uploading random String to gcs but I got stuck at the beginning itself while creating a Storage service object

Maven依赖

 <dependency>
   <groupId>com.google.cloud</groupId>
   <artifactId>google-cloud-storage</artifactId>
   <version>1.70.0</version>
 </dependency>


import com.google.cloud.storage.*;
Storage storage = StorageOptions.getDefaultInstance().getService();
    BlobId blobId = BlobId.of("bucket_name", "test_upload/test.txt");
    BlobInfo blobInfo = BlobInfo.newBuilder(blobId).setContentType("text/plain").build();
    Blob blob = storage.create(blobInfo, "Hello, Cloud Storage!".getBytes(UTF_8));
    System.out.println(blob);

编译时错误:

[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.1:compile (default-compile) on project gcshelper: Compilation failure: Compilation failure: 
ERROR] /Users/v3/gcshelper/src/main/java/com/tv/gcs/GcsTest.java:[16,41] cannot access com.google.cloud.ServiceOptions [ERROR] class file for com.google.cloud.ServiceOptions not found [ERROR] /Users/v3/gcshelper/src/main/java/com/tv/gcs/GcsTest.java:[19,28] cannot access com.google.cloud.Service [ERROR] class file for com.google.cloud.Service not found [ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch. [ERROR] Re-run Maven using the -X switch to enable full debug logging.

推荐答案

<dependency>
 <groupId>com.google.cloud</groupId>
 <artifactId>google-cloud</artifactId>
 <version>0.47.0-alpha</version>
</dependency>

解决了我的问题

这篇关于如何解析com.google.cloud.Service的类文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆