[英]Google Cloud Datastore API Java
I have managed to import a version of the Google Cloud Datastore API in my project on Eclipse using Google Plugin Tool, yeah I know it is not a great achievement! 我已经使用Google Plugin Tool在Eclipse上的项目中成功导入了一个版本的Google Cloud Datastore API,是的,我知道这不是一个很大的成就!
But now what do I do....??? 但是现在我该怎么办.... ???
I can not find any correct functions for this API, either the functions are not resolved, or in other cases the imports are not resolved... 我找不到此API的任何正确函数,或者函数未解析,或者在其他情况下无法解析导入...
I am just trying to find a way to store some data on the Google Cloud. 我只是想找到一种在Google Cloud上存储一些数据的方法。 I am looking for just a few lines of Java code, something along the lines:
我在寻找的只是Java代码的几行,大致如下:
import com.blah.blahblah
.
.
.
main{
Datastore mydata;
mydata.put("Name", "myName"); }
Sort of thing. 那类的东西。 From all my reading for the past few days, it seems there are a couple of different APIs and I am using the wrong function names with the wrong API and I can't figure out how to match up the two...please some help as I am getting : (((
从过去几天的所有阅读中,似乎有几个不同的API,并且我使用了错误的函数名和错误的API,但我不知道如何将两者匹配...请寻求帮助当我越来越:(((
Thank you. 谢谢。
If all you are trying to do is store data on the Google cloud, you have a few options. 如果您要做的就是将数据存储在Google云中,那么您可以选择几种方法。 the datastore, the blobstore, CloudSQL and the Cloud Storage.
数据存储区,blobstore,CloudSQL和云存储。 Each has its own unique strengths.
每个人都有其独特的优势。 Seems to me what you are looking for is a way to get started with an API, and I would recommend starting with this example: https://developers.google.com/appengine/docs/java/gettingstarted/introduction
在我看来,您正在寻找的是一种开始使用API的方法,我建议从以下示例开始: https : //developers.google.com/appengine/docs/java/gettingstarted/introduction
Using the Google Cloud Java client libraries: 使用Google Cloud Java客户端库:
import com.google.cloud.datastore.Datastore;
import com.google.cloud.datastore.DatastoreOptions;
import com.google.cloud.datastore.Entity;
import com.google.cloud.datastore.Key;
import com.google.cloud.datastore.KeyFactory;
Datastore datastore = DatastoreOptions.getDefaultInstance().getService();
KeyFactory keyFactory = datastore.newKeyFactory().setKind("myKind");
Key key = keyFactory.newKey("myKey");
Entity entity = Entity.newBuilder(key)
.set("name", "Jane Doe")
.set("age", 40)
.build();
datastore.put(entity);
You can view the API documentation here , and don't forget you need to setup authentication correctly . 您可以在此处查看API文档 ,并且不要忘记需要正确设置身份验证 。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.