简体   繁体   English

如何在 Google App Engine 中更改目标网址

[英]How to change the target URL in Google App Engine

I'm trying to do App Engine with endpoints.我正在尝试使用端点执行 App Engine。 When I deploy the app, the server takes the project ID of the other basic App Engine project I have.当我部署应用程序时,服务器采用我拥有的其他基本 App Engine 项目的项目 ID。 In the trace I found that the target project, target service, target version, and target url all are that of the basic App Engine project.在跟踪中我发现目标项目、目标服务、目标版本和目标 url 都是基本 App Engine 项目的。

The trace is as follows:跟踪如下:

target project:  [testniit1]
[INFO] GCLOUD: target service:  [default]
[INFO] GCLOUD: target version:  [20171024t130444]
[INFO] GCLOUD: target url:      [https://testniit1.appspot.com]

( Image of the trace ) 痕迹图像

But my actual project ID / project URL is endpoint2-2.appspot.com .但我的实际项目 ID/项目 URL 是endpoint2-2.appspot.com

How can I change the default/target URL?如何更改默认/目标 URL?

First of all, App Engine as of writing has a one-to-one correspondence between app and project.首先,在撰写本文时,App Engine 在应用程序和项目之间具有一一对应的关系。 See https://stackoverflow.com/a/46047030/1161743 for more details.有关更多详细信息,请参阅https://stackoverflow.com/a/46047030/1161743

However you can declare services within App Engine that will give you what you want.但是,您可以在 App Engine 中声明可以满足您需求的服务。

In app.yaml:在 app.yaml 中:

service: foo-bar

This will generate:这将生成:

[INFO] GCLOUD: target url:      [https://foo-bar-dot-project-name.appspot.com]

From what I have seen, the project ID is a unique identifier that can be found at https://console.cloud.google.com/home/dashboard .据我所知,项目 ID 是一个唯一标识符,可以在https://console.cloud.google.com/home/dashboard找到。 Make sure your project is selected, then look under "Project Info" at the top left.确保选择了您的项目,然后查看左上角的“项目信息”。

After you have that info, you can set the project in your Google Cloud SDK Shell by typing in the command gcloud config set project <projectID>获得该信息后,您可以通过键入命令gcloud config set project <projectID>在 Google Cloud SDK Shell 中gcloud config set project <projectID>

Official CLI documentation: https://cloud.google.com/sdk/gcloud/reference/config/set官方 CLI 文档: https : //cloud.google.com/sdk/gcloud/reference/config/set

You can deploy to different service to get this done.您可以部署到不同的服务来完成这项工作。

https://VERSION_ID-dot-SERVICE_ID-dot-PROJECT_ID.REGION_ID.r.appspot.com https://VERSION_ID-dot-SERVICE_ID-dot-PROJECT_ID.REGION_ID.r.appspot.com

you can add your service in yaml file if it is node project.如果是节点项目,您可以在 yaml 文件中添加您的服务。 Or add it in pom file if it is JAVA.或者如果是JAVA,则将其添加到pom文件中。

More info更多信息

Check you appengine-web.xml - the testniit1 should be defined there in <application>_your_app_id_</application> tag.检查您的appengine-web.xml - testniit1应该在<application>_your_app_id_</application>标签中定义。

End-points should be a part of your path, eg:端点应该是您路径的一部分,例如:

https://YOU_APP_ID.appspot.com/SOME_OPTIONAL_PREFIX/ENDPOINT_NAME

Also you can use modules, then the url could looks like:您也可以使用模块,然后网址可能如下所示:

https://ENDPOINT_MODULE.YOU_APP_ID.appspot.com/SOME_OPTIONAL_POSTFIX

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM