gpt4 book ai didi

spring - 如何从环境变量添加事件的 Spring 配置文件?

转载 作者:行者123 更新时间:2023-12-02 11:42:51 26 4
gpt4 key购买 nike

到目前为止,我在 ~/.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/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com