[英]Override application.yml with environment variable in Spring boot
I need my application should pick value of a key from environment variables instead of application.yml.我需要我的应用程序应该从环境变量而不是 application.yml 中选择一个键的值。
If a particular property is available in both environment variables as well as in appliation.yml
then it should pick the value which is specified as part of environment variables.如果特定属性在环境变量和appliation.yml
中都可用,那么它应该选择指定为环境变量一部分的值。
If a particular property is not there in environment variables then it should pick value from application.yml
else not.如果环境变量中没有特定属性,那么它应该从application.yml
中选择值,否则不。
For your two questions.对于你的两个问题。 You can use something like:你可以使用类似的东西:
spring:
profiles: ${YOUR_ENV_FOR_PROFILE:YOUR_DEFAULT_PROFILE}
If you set an environment variable(Ex. YOUR_ENV_FOR_PROFILE) then spring use it, otherwise spring use a default value "YOUR_DEFAULT_PROFILE"如果设置环境变量(例如 YOUR_ENV_FOR_PROFILE),则 spring 使用它,否则 spring 使用默认值“YOUR_DEFAULT_PROFILE”
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.