作为我最后一年项目的一部分,我正在使用适用于 Java 的 Cloud Endpoints Frameworks (2.0.1),并且到目前为止相对成功。部署到我的 appspot.com 域时没有任何问题,但是在本地部署时遇到了一些问题。
(以下代码块中对 my-project-id 的任何引用都是我的实际谷歌云项目 ID 的别名)
我有一个带注释的@API 类的有效openapi 描述符(openapi.json),我正在使用“gcloud service-management deploy openapi.json”将其部署到云端点。命令返回成功:
Service Configuration [2017-02-23r0] uploaded for service [api.endpoints.<my-project-id>.cloud.goog]
然后我将返回的 config_id 映射到我的 app.yaml 中的正确 endpoints_api_service
endpoints_api_service:
name: api.endpoints.<my-project-id>.cloud.goog
config_id: 2017-02-23r0
此服务由 gcloud cli 工具使用“gcloud service-management list”列出
NAME TITLE
storage-component.googleapis.com Google Cloud Storage
api.endpoints.<my-project-id>.cloud.goog api.endpoints.<my-project-id>.cloud.goog
etc...
和“gcloud service-management configs list --service api.endpoints.my-project-id.cloud.goog”
CONFIG_ID SERVICE_NAME
2017-02-23r0 api.endpoints.<my-project-id>.cloud.goog
... other version configs
并且可以在我的 appspot.com 域上访问(我可以调用端点并接收正确的响应)
我正在尝试使用 java 的 maven appengine 插件(mvn appengine:devserver)在 localhost 上部署我的项目,但是在码头启动时,我遇到了以下异常:
WARNING: Failed startup of context com.google.appengine.tools.development.DevAppEngineWebAppContext...
com.google.api.config.ServiceConfigException: Failed to fetch default config version for service 'api.endpoints.<my-project-id>.cloud.goog'. No versions exist!
at com.google.api.config.ServiceConfigSupplier.fetchLatestServiceVersion(ServiceConfigSupplier.java:155)
....
然后,部署陷入无休止的循环,尝试启动码头,并被该错误消息击中,然后重新启动等。任何访问 localhost:8080 的尝试都会导致“503:找不到服务”错误
我假设我的应用程序的本地部署能够访问使用“gcloud service-management deploy”部署的服务配置,就像appspot.com 部署一样,但不是这样吗?查看 ServiceConfigSupplier.getchLatestServiceVersion() 的源代码,我收集到 serviceManagement.services().configs().list(my-service-name).execute().getServiceConfigs() 正在返回一个空列表,但为什么这只是发生在本地?
额外的信息
我的 ENDPOINTS_SERVICE_NAME 环境变量匹配“api.endpoints.my-project-id.cloud.goog”
我注意到几天前 com.google.api.config 有一个更新(1.0.2),它依赖于旧版本的 com.google.api.services.servicemanagement(依赖于 v1-rev14 -1.22.0,最新版本是 v1-rev340-1.22.0)我怀疑这是问题所在,但我想我会提到它,因为它包含与异常相关的类(ServiceManagement 由 ServiceConfigSupplier 使用,它正在抛出例外)。也许他们在哪里寻找服务配置不一致?
我很困惑,这有点过头了。我不喜欢必须删除端点,因为我开始喜欢它,但我们也不能真正失去对开发服务器的使用。我希望有人可以对这个问题有所了解。