【问题标题】:Using 'Google Cloud Datastore API Client Library for Java' with Gradle将“Java 版 Google Cloud Datastore API 客户端库”与 Gradle 一起使用
【发布时间】:2016-10-12 10:16:52
【问题描述】:

我正在尝试将 Google Cloud Datastore 用于 Android 应用中的简单读/写功能。

我转到this 页面并编译了这个“compile 'com.google.apis:google-api-services-datastore:v1beta2-rev31-1.22.0'”gradle 依赖项以及 MavenCentral 存储库。

然后我进入批处理文档here,但编译后的 gradle 库缺少此示例代码中使用的 Calender 类:

JsonBatchCallback<Calendar> callback = new JsonBatchCallback<Calendar>() {

  public void onSuccess(Calendar calendar, HttpHeaders responseHeaders) {
    printCalendar(calendar);
    addedCalendarsUsingBatch.add(calendar);
  }

  public void onFailure(GoogleJsonError e, HttpHeaders responseHeaders) {
    System.out.println("Error Message: " + e.getMessage());
  }
};

...

Calendar client = Calendar.builder(transport, jsonFactory, credential)
  .setApplicationName("BatchExample/1.0").build();
BatchRequest batch = client.batch();

Calendar entry1 = new Calendar().setSummary("Calendar for Testing 1");
client.calendars().insert(entry1).queue(batch, callback);

Calendar entry2 = new Calendar().setSummary("Calendar for Testing 2");
client.calendars().insert(entry2).queue(batch, callback);

batch.execute();

我需要编译哪些其他依赖项才能获得该类?

我用谷歌搜索并查看了其他 stackoverflow 问题 here 和示例项目 here,我似乎找不到如何使用 Google Datastore 进行 CRUD 操作的简单演示。有人可以向我指出一些综合文档/教程的方向,该教程解释了如何在不使用 Google App Engine 的情况下在 Google Datastore 上执行 CRUD 操作?

提前致谢

【问题讨论】:

  • 为什么这个问题被否决了?
  • 要求我们推荐或查找书籍、工具、软件库、教程或其他非现场资源的问题对于 Stack Overflow 来说是题外话,因为它们往往会吸引固执己见答案和垃圾邮件。
  • 感谢您的解释,非常感谢

标签: java android crud google-api-java-client google-cloud-datastore


【解决方案1】:

如您的链接页面中所述:

使用日历 API 的批处理的完整示例可在 日历命令行示例。

Calendar API 主页位于:

https://developers.google.com/api-client-library/java/apis/calendar/v3

这里显示 Gradle 脚本需要:

repositories {
    mavenCentral()
}

dependencies {
    compile 'com.google.apis:google-api-services-calendar:v3-rev191-1.22.0'
}

【讨论】:

  • 感谢您的回答。我将更多地研究这个例子。我还找到了this library。
猜你喜欢
  • 1970-01-01
  • 2015-03-04
  • 1970-01-01
  • 2017-04-13
  • 1970-01-01
  • 2014-04-23
  • 1970-01-01
  • 1970-01-01
  • 2014-08-11
相关资源
最近更新 更多