简体   繁体   English

无法使用JAVA中的parse4j API在Parse.com中插入对象

[英]Cannot insert object in Parse.com with parse4j API in JAVA

I am using Parse.com for communicating with iOS application and Web Browser. 我正在使用Parse.com与iOS应用程序和Web浏览器进行通信。 I have registered in parse.com and created an application. 我已经在parse.com中注册并创建了一个应用程序。 Now I have an iOS application ready to insert an object in that application which is working fine. 现在,我已经准备好一个iOS应用程序,可以在该应用程序中插入一个正常工作的对象。 Now comes the backend part, I am using JAVA for web application. 现在是后端部分,我正在将JAVA用于Web应用程序。 Now, 现在,

https://parse.com/docs/api_libraries https://parse.com/docs/api_libraries

According to this link, I can see the API/ Libraries I can use in JAVA is 根据此链接,我可以看到我可以在JAVA中使用的API /库是

Almonds mobile-parse-api Parse4j ParseFacade 杏仁mobile-parse-api Parse4j ParseFacade

Among this 4, I have selected Parse4j to build web application with. 在这4个中,我选择了Parse4j来构建Web应用程序。

I am using Eclipse, I have installed GWT plugin, created a web application. 我正在使用Eclipse,已经安装了GWT插件,创建了一个Web应用程序。 Now I am adding this parse4j.jar file to that project, Added it to the build path also. 现在,我将此parse4j.jar文件添加到该项目中,并将其也添加到构建路径中。 And then I try to write this code 然后我尝试编写这段代码

try {

        Parse.initialize("my app id", "my rest app id");        

        ParseObject gameScore = new ParseObject("GameScore");
        gameScore.put("score", 1337);
        gameScore.put("playerName", "Sean Plott");
        gameScore.put("cheatMode", false);
        gameScore.save();

        return "OK";
    } catch(IllegalArgumentException e){
        e.printStackTrace();
        return "KO";
    }
    catch(ParseException e){
        e.printStackTrace();
        return "KO";
    }

It doesn't insert the object to parse cloud. 它不会插入对象来解析云。 Please help why isn't working? 请帮助为什么不起作用? Am I missing anything to write? 我想念什么东西吗?

As far as I see, the code is correct. 据我所知,代码是正确的。 However, if Parse4j does not save the entry this means that you write wrong the attribute name or class name. 但是,如果Parse4j没有保存该条目,则意味着您写错了属性名称或类名称。 Just check the names and class name then reply back. 只需检查名称和班级名称,然后回复即可。

Regards. 问候。

One way to validate is the do a Query, get the object and print all the attributes / data types. 验证的一种方法是执行查询,获取对象并打印所有属性/数据类型。 Then store these as static class level constants and use them throughout your class for setting values in new objects to persist. 然后将它们存储为静态类级别常量,并在整个类中使用它们在新对象中设置值以持久化。

If the get query doesn't work (without any filters), which means your class name is incorrect. 如果get查询不起作用(没有任何过滤器),则表明您的类名不正确。

Good Luck! 祝好运!

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM