如何部署多个 Java services到同一个 GCP 项目吗?
文档中提到了在 appengine-web.xml 中指定项目 ID[1];
The
<application>
element contains the application's project ID. This is the project ID you register when you create your project in the Google Cloud Platform Console.
但它被 gcloud
忽略和mvn
[1] [2](强调我的):
gcloud and gcloud tooling (Intellij, Gradle, and the new maven plug-ins) ignore this element
Note that while every appengine-web.xml file must contain the
<application>
tag, the name you supply there is ignored. The name of the application is taken from the<application>
tag in the appengine-application.xml file.
最后一句话似乎适用于 Java 8/Jetty 9 运行时。
java-gae-quickstart 项目没有 appengine-application.xml 文件。
最佳答案
这是一个使用模块的示例项目:https://github.com/GoogleCloudPlatform/appengine-modules-sample-java
注释:
- 有一个“ear”模块,它不包含代码,但有一个 application.xml 。该文件定义了您的项目的模块。
- 有一个模块(“ear”除外)没有定义模块名称(在 appengine-web.xml 中)或模块名称为“default”,这一点很重要。这也是用于配置数据存储索引、cron 等的模块。
- 为了部署所有模块,您需要转到 Ear 模块并执行
mvn appengine:update
关于java - 如何将多个Java服务部署到同一个GCP项目,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40126181/