# 60.1 Cloud Foundry

如果不指定其他打包方式，Cloud Foundry会启用它提供的默认打包方式。Cloud Foundry的[Java buildpack](https://github.com/cloudfoundry/java-buildpack)对Spring应用有出色的支持，包括Spring Boot。你可以部署独立的可执行jar应用，也可以部署传统的`.war`形式的应用。

一旦你构建应用（比如，使用`mvn clean package`）并[安装`cf`命令行工具](https://docs.cloudfoundry.org/cf-cli/install-go-cli.html)，你可以使用下面的`cf push`命令（将路径指向你编译后的`.jar`）来部署应用。在发布应用前，确保[你已登陆cf命令行客户端](https://docs.cloudfoundry.org/cf-cli/getting-started.html#login)。下面的代码行展示了如何使用`cf push`命令来部署应用程序：

```
$ cf push acloudyspringtime -p target/demo-0.0.1-SNAPSHOT.jar
```

**注** 在前面的例子中，我们将`acloudyspringtime`替换为你为应用程序指定的`cf`值。

查看[`cf push`文档](https://docs.cloudfoundry.org/cf-cli/getting-started.html#push)获取更多可选项。如果相同目录下存在[manifest.yml](https://docs.cloudfoundry.org/devguide/deploy-apps/manifest.html)，Cloud Foundry会使用它。

就此，`cf`将开始上传你的应用，生成如下图所示的输出：

```
Uploading acloudyspringtime... OK
Preparing to start acloudyspringtime... OK
-----> Downloaded app package (8.9M)
-----> Java Buildpack Version: v3.12 (offline) | https://github.com/cloudfoundry/java-buildpack.git#6f25b7e
-----> Downloading Open Jdk JRE 1.8.0_121 from https://java-buildpack.cloudfoundry.org/openjdk/trusty/x86_64/openjdk-1.8.0_121.tar.gz (found in cache)
       Expanding Open Jdk JRE to .java-buildpack/open_jdk_jre (1.6s)
-----> Downloading Open JDK Like Memory Calculator 2.0.2_RELEASE from https://java-buildpack.cloudfoundry.org/memory-calculator/trusty/x86_64/memory-calculator-2.0.2_RELEASE.tar.gz (found in cache)
       Memory Settings: -Xss349K -Xmx681574K -XX:MaxMetaspaceSize=104857K -Xms681574K -XX:MetaspaceSize=104857K
-----> Downloading Container Certificate Trust Store 1.0.0_RELEASE from https://java-buildpack.cloudfoundry.org/container-certificate-trust-store/container-certificate-trust-store-1.0.0_RELEASE.jar (found in cache)
       Adding certificates to .java-buildpack/container_certificate_trust_store/truststore.jks (0.6s)
-----> Downloading Spring Auto Reconfiguration 1.10.0_RELEASE from https://java-buildpack.cloudfoundry.org/auto-reconfiguration/auto-reconfiguration-1.10.0_RELEASE.jar (found in cache)
Checking status of app 'acloudyspringtime'...
  0 of 1 instances running (1 starting)
  ...
  0 of 1 instances running (1 starting)
  ...
  0 of 1 instances running (1 starting)
  ...
  1 of 1 instances running (1 running)

App started
```

恭喜！应用现在处于运行状态！

应用程序启动后，可以使用`cf apps`命令验证部署的应用程序的状态，如下例所示：

```
$ cf apps
Getting applications in ...
OK

name                 requested state   instances   memory   disk   urls
...
acloudyspringtime    started           1/1         512M     1G     acloudyspringtime.cfapps.io
...
```

一旦Cloud Foundry意识到你的应用已经部署，你就可以点击给定的应用URI。在前面的示例中，你可以通过[http://acloudyspringtime.cfapps.io/](http://acloudyspringtime.cfapps.io/)找到它。
