繁体   English   中英

我可以使用 Java 8 运行时使用 App Engine Standard 在运行时设置环境变量吗

[英]Can I set environment variables at runtime with App Engine Standard using Java 8 runtime

As for the official documentation ( https://cloud.google.com/appengine/docs/standard/java/config/appref ), a Java application using App Engine Standard for Java 8 runtime should describe it's env in an appengine-web.xml位于WEB-INF文件夹下。

这些变量因环境而异的可能性很高,我拒绝构建环境专用的工件。

我可以在外部文件中设置这些环境变量吗? 如果是怎么办?

为了在 Java 运行时中为 App Engine 设置环境变量,您还可以使用 env_variables 键在 app.yaml 文件中设置它们

例如:

env_variables:
   MY_VAR_COLOR: 'blue'

您可以在此处查看推荐的文档

您不能为环境变量定义包含外部文件。

为此,我复制了appengine-web.xml并将其存储在单独的子文件夹WEB-INF/dev/WEB-INF/uat/WEB-INF/prod/

然后,我使用 Maven 根据传递给 build -P参数的配置文件从右侧子文件夹复制appengine-web.xml

不是很容易维护,因为您必须在所有appengine-web.xml文件中复制修改,但我没有找到更好的折衷方法来为每个环境提供单独的价值。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM