55.1 Cloud Foundry
如果不指定其他打包方式,Cloud Foundry会启用它提供的默认打包方式。Cloud Foundry的Java buildpack对Spring应用有出色的支持,包括Spring Boot。你可以部署独立的可执行jar应用,也可以部署传统的.war
形式的应用。
一旦你构建应用(比如,使用mvn clean package
)并安装cf
命令行工具,你可以使用下面的cf push
命令(将路径指向你编译后的.jar
)来部署应用。在发布应用前,确保你已登陆cf命令行客户端。
$ cf push acloudyspringtime -p target/demo-0.0.1-SNAPSHOT.jar
查看cf push
文档获取更多可选项。如果相同目录下存在manifest.yml,Cloud Foundry会使用它。
就此,cf
将开始上传你的应用:
Uploading acloudyspringtime... OK
Preparing to start acloudyspringtime... OK
-----> Downloaded app package (8.9M)
-----> Java Buildpack source: system
-----> Downloading Open JDK 1.7.0_51 from .../x86_64/openjdk-1.7.0_51.tar.gz (1.8s)
Expanding Open JDK to .java-buildpack/open_jdk (1.2s)
-----> Downloading Spring Auto Reconfiguration from 0.8.7 .../auto-reconfiguration-0.8.7.jar (0.1s)
-----> Uploading droplet (44M)
Checking status of app 'acloudyspringtime'...
0 of 1 instances running (1 starting)
...
0 of 1 instances running (1 down)
...
0 of 1 instances running (1 starting)
...
1 of 1 instances running (1 running)
App started
恭喜!应用现在处于运行状态!
检验部署应用的状态是很简单的:
$ 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,此处是acloudyspringtime.cfapps.io/。