【问题标题】:Google App Engine local Datastore after SDK upgradeSDK 升级后的 Google App Engine 本地数据存储
【发布时间】:2013-04-10 12:38:12
【问题描述】:

我刚刚升级到 SDK 1.7.7,我的应用程序无法再访问本地数据存储。我google了一下,发现这通常是在升级SDK时发生的。

我似乎找不到任何可以让我保留现有数据的解决方案。我已经在我的数据存储中设置了大量的测试数据,我不想重新创建这些数据。有什么方法可以将本地数据存储中的数据从一个 SDK 版本转换/迁移到另一个版本?

【问题讨论】:

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


    【解决方案1】:

    我使用的步骤是:

    1) 建立remote_api 连接https://developers.google.com/appengine/articles/remote_api

    类似

        static RemoteApiOptions options;
        options = new RemoteApiOptions().server("localhost", 8888).credentials("", ""); // password doesn't matter
    
        RemoteApiInstaller installer = new RemoteApiInstaller();
        installer.install(options);
    

    2) 获取我的数据(这适用于我使用 Objectify,但您通常会这样做)

                UserDAO udao = new UserDAO(false);
                Query<UserOFY> qu = udao.ofy().query(UserOFY.class);
    

    3) 将我的数据保存到硬盘

    类似

                FileOutputStream fileOut = new FileOutputStream(LOCAL_AE_BACKUPS_USER + "/" + USERS_FROM_LOCAL_BACKUP + "_" + u.getNickName());
                ObjectOutputStream out = new ObjectOutputStream(fileOut);
                out.writeObject(u);
                out.close();
    

    那我升级版本后就反过来了。

    1) 读取我硬盘上的持久化数据

    2) 与本地数据存储建立连接

    3) 将数据持久化到新版本的本地数据存储中

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2011-09-23
      • 1970-01-01
      • 2011-05-26
      • 2016-01-18
      • 2011-03-27
      相关资源
      最近更新 更多