【发布时间】:2016-06-10 16:15:08
【问题描述】:
我对谷歌应用引擎和端点非常陌生,并且一直在编写基本的端点功能并部署到云端。我成功部署了一个 HelloWorld 端点并通过 API 资源管理器对其进行了测试:http://localhost:8080/_ah/api/explorer
但是现在,当我创建了一个新的端点 API 并遵循相同的步骤(即在 appengine-web.xml 中使用新的 APP 引擎应用程序名称部署,运行为 appengine:update)时,api explorer 仍然显示我的 HelloWorld 端点而不是我的新 API“yourfirstendpoint”。
我已经搜索并试图找到一个无济于事的答案 - 如果这是我的一个非常基本和愚蠢的问题,我很抱歉(我确定是),但如果有人能指出我,我将不胜感激我应该做的事情的正确方向。
我的 API
package com.example.zinglife;
import com.google.api.server.spi.config.Api;
import com.google.api.server.spi.config.ApiMethod;
import com.google.api.server.spi.config.ApiMethod.HttpMethod;
import com.google.api.server.spi.response.NotFoundException;
import com.google.appengine.api.datastore.Key;
import com.google.appengine.api.datastore.KeyFactory;
/**
*
* Defines endpoint functions APIs.
*/
@Api(name = "yourfirstapi", version = "v1",
scopes = {Constants.EMAIL_SCOPE },
clientIds = {Constants.API_EXPLORER_CLIENT_ID},
description = "API for hello world endpoints.")
public class YourFirstAPI
{
@ApiMethod(name = "storeUserModel")
private User storeUserModel(User user) throws NotFoundException
{
String email = user.getEmail();
Key key = KeyFactory.createKey("User",email);
User userEntity = null;
try
{
if (userEntity==null)
{
userEntity = new User();
userEntity.setName(user.getName());
userEntity.setEmail(user.getEmail());
userEntity.setCountry(user.getCountry());
//
}
return userEntity;
}//*endtry
finally
{
}
}
}
运行代码后的 App Engine 管理员日志:
如果需要任何其他信息,请告诉我:)
【问题讨论】:
-
api 浏览器有时会出现故障。一般来说,您应该看到端点 api。如果你不这样做,这里有一些可能性:你可能没有正确生成和部署发现文档,你上传了一个新版本,但你没有默认切换到这个版本,你的浏览器中有过时的数据,应该清除浏览器缓存,您忘记在 web.xml 中的
com.google.api.server.spi.SystemServiceServletinit-params 添加一个新的 api 类。
标签: google-app-engine google-cloud-endpoints