如需在 App Engine 上部署应用,您必须创建一个 Google Cloud 项目,该项目是一个用于存放 App Engine 应用资源及其他 Google Cloud 资源的顶层容器。
在本任务中,您将创建一个 Google Cloud 项目和一个 App Engine 应用来存储应用的设置、计算资源、凭证和元数据。
如果您已有启用了 App Engine 和 Cloud Build API 的 Google Cloud 项目,则可以继续编写 Web 服务。
创建 Google Cloud 项目
- Sign in to your Google Cloud account. If you're new to Google Cloud, create an account to evaluate how our products perform in real-world scenarios. New customers also get $300 in free credits to run, test, and deploy workloads.
-
In the Google Cloud console, on the project selector page, select or create a Google Cloud project.
-
Verify that billing is enabled for your Google Cloud project.
-
Enable the Cloud Build API.
-
Install the Google Cloud CLI.
-
如果您使用的是外部身份提供方 (IdP),则必须先使用联合身份登录 gcloud CLI。
-
如需初始化 gcloud CLI,请运行以下命令:
gcloud init
-
In the Google Cloud console, on the project selector page, select or create a Google Cloud project.
-
Verify that billing is enabled for your Google Cloud project.
-
Enable the Cloud Build API.
-
Install the Google Cloud CLI.
-
如果您使用的是外部身份提供方 (IdP),则必须先使用联合身份登录 gcloud CLI。
-
如需初始化 gcloud CLI,请运行以下命令:
gcloud init
在 Google Cloud 控制台中为您的 Google Cloud 项目创建 App Engine 应用。
选择您希望应用的计算资源所位于的区域。
- 由于在新项目中 Cloud Build 使用服务账号的默认行为发生变化,以及从设计上保证安全的组织政策发生变化,您可能需要向部署服务账号授予额外的角色。如需详细了解如何授予特定角色,请参阅问题排查指南。
后续步骤
现在您的 Google Cloud 项目已设置完毕,您可以开始使用 Java 编写基本的Web 服务了。