到目前为止,我在 ~/.bash_profile
中设置以下环境变量:
export SPRING_PROFILES_ACTIVE=local
这设置了我的事件 Spring 配置文件。但现在,我想将本地配置文件添加到application.properties
中定义的其他配置文件,而不是替换它们。
在 Spring Boot documentation ,有一个关于添加事件配置文件的部分,但我没有看到任何有关从环境变量添加事件配置文件的内容。
我尝试设置 SPRING_PROFILES_INCLUDE
环境变量,但这没有效果。
如何做到这一点?
P.S.:我使用的是 Spring Boot 1.4.2。
最佳答案
您链接到的文档中的下一句话:
Sometimes it is useful to have profile-specific properties that add to the active profiles rather than replace them. The
spring.profiles.include
property can be used to unconditionally add active profiles.
因此您可以使用命令行参数启动应用程序:
-Dspring.profiles.include=${SPRING_PROFILES_INCLUDE}
关于spring - 如何从环境变量添加事件的 Spring 配置文件?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40637544/