java - GAE 远程 API - 无法连接

标签 java google-app-engine google-cloud-datastore

好的,我正在尝试连接到远程数据存储并使用此处概述的步骤从我的本地计算机进行填充,但未成功:https://cloud.google.com/appengine/docs/java/tools/remoteapi#Configuring_Remote_API_on_the_Client

public static void main(String[] args) {

    String username = "myemail@gmail.com";
    String password = "mygmailpassword";
    RemoteApiOptions options = new RemoteApiOptions()
        .server("myappname.appspot.com", 443)
        .credentials(username, password);
    RemoteApiInstaller installer = new RemoteApiInstaller();
    installer.install(options);

    try {       
        DatastoreService ds = DatastoreServiceFactory.getDatastoreService();
        ...

我在 installer.install(options) 中收到 404: java.io.IOException: 无法从远程 api 获取 appId;状态码 = 404 我在这里错过了什么吗?我在我的 web.xml 中启用了远程 api 并部署到 GAE。我是项目的所有者。

最佳答案

在本地运行您的服务(启用远程 api)并尝试使用“localhost”和 8888(端口)运行相同的代码并检查您的代码是否可以访问本地运行的服务。您的代码似乎是正确的。有两种可能性—— 1. RemoteApi没有正确启用。 2. app-name拼写错误。

除此之外,我还使用以下代码访问远程 api-

        installer.install(options);
        try {
            // Update the options with reusable credentials so we can skip
            // authentication on subsequent calls.
            options.reuseCredentials(username, installer.serializeCredentials());
        } finally {
            installer.uninstall();
        }

但是,这不应该给你你得到的错误。

关于java - GAE 远程 API - 无法连接,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27769581/

相关文章:

java - JTextArea 在 actionListener 之前填充

java - 获取错误 : cannot resolve symbol for 'compress' for bitmap. 压缩(Bitmap.CompressFormat.PNG,0,流);

java - Android Studio - 编译错误 : (App keeps stopping) -> RuntimeException: Unable to instantiate activity

java - Eclipse Luna Gradle插件添加了未引用的依赖项

google-app-engine - 检查对象是否存在的最快方法

java - CompletableFuture 没有按预期工作

google-app-engine - 在本地恢复应用引擎实体

Google App Engine 以外的 Python 云托管?

mysql - 如何连接安装在谷歌云上的mysql

google-app-engine - GAE : Getting key of entity just created