首页 > 解决方案 > 如何在本地检查或查看使用 gcloud 数据存储存储的数据?

问题描述

我有以下单元测试

  public void testStoreGroceryList() {
    Grocery beer = new Grocery("Beer", 10);
    GroceryList groceryList = new GroceryList();
    groceryList.addGrocery(beer);

    Grocery bread = new Grocery("Bread", 1);
    groceryList.addGrocery(bread);

    assert(groceryList.getNumberOfGroceries() > 0);

    ofy().save().entity(groceryList).now();

    assert(groceryList.id != null);
  }

我在执行测试时正在运行 glcoud 模拟器,一切正常,没有失败的测试。但是如何访问本地数据存储?我的模拟器在端口 8484 上运行,但http://localhost:8484/_ah/admin给了我Not Found

如果我运行 mvn appengine:run 我看到数据存储可供我使用,但是如何在运行单元测试时访问它以查看我存储的数据的样子?

我已经跑gcloud beta emulators datastore env-init了,得到了

export DATASTORE_DATASET=grocery-monkey
export DATASTORE_EMULATOR_HOST=localhost:8484
export DATASTORE_EMULATOR_HOST_PATH=localhost:8484/datastore
export DATASTORE_HOST=http://localhost:8484
export DATASTORE_PROJECT_ID=grocery-monkey

但我仍然无法访问 _ah/admin

标签: javagclouddatastore

解决方案


推荐阅读