# 60.6 Google Cloud

谷歌云有几个用于启动Spring Boot应用程序的选项。最简单的入门方法可能是App Engine，但是你也可以找到用Container Engine在容器中运行Spring Boot的方法，或者用Compute Engine在虚拟机中运行Spring Boot的方法。

要在App Engine中运行，你可以首先在UI中创建一个项目，它为您设置一个惟一的标识符，并设置HTTP路由。将一个Java应用程序添加到项目中，并保持它为空，然后使用[谷歌云SDK](https://cloud.google.com/sdk/downloads)将你的Spring Boot应用程序从命令行或CI构建推入该位置。

App Engine需要你创建一个`app.yaml`文件来描述应用程序所需的资源。通常，你把这个文件放在`src/main/appengine`，它应该类似于以下文件:

```
service: default

runtime: java
env: flex

runtime_config:
  jdk: openjdk8

handlers:
- url: /.*
  script: this field is required, but ignored

manual_scaling:
  instances: 1

health_check:
  enable_health_check: False

env_variables:
  ENCRYPT_KEY: your_encryption_key_here
```

你可以通过将项目ID添加到构建配置中来部署应用程序(例如，使用Maven插件)，如下面的示例所示：

```markup
<plugin>
    <groupId>com.google.cloud.tools</groupId>
    <artifactId>appengine-maven-plugin</artifactId>
    <version>1.3.0</version>
    <configuration>
        <project>myproject</project>
    </configuration>
</plugin>
```

然后使用`mvn appengine:deploy`进行部署（如果需要首先进行身份验证，则构建将失败）。

**注** 谷歌App Engine Classic与Servlet 2.5 API绑定在一起，因此如果不进行一些修改，就不能在那里部署Spring应用程序。请参阅本指南的[Servlet 2.5部分](https://docs.spring.io/spring-boot/docs/2.0.0.RELEASE/reference/htmlsingle/#howto-servlet-2-5)。


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://jack80342.gitbook.io/spring-boot/vi.-deploying-spring-boot-applications/60.-deploying-to-the-cloud/60.6-google-cloud.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
