Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

环境变量覆盖apollo配置失败 #5009

Closed
3 tasks done
ZeroSong211 opened this issue Nov 6, 2023 · 9 comments
Closed
3 tasks done

环境变量覆盖apollo配置失败 #5009

ZeroSong211 opened this issue Nov 6, 2023 · 9 comments
Labels

Comments

@ZeroSong211
Copy link

ZeroSong211 commented Nov 6, 2023

描述bug

多个应用引用同一个apollo配置时,不同应用间的配置差异我们采用了环境变量去覆盖apollo配置。但使用过程中,发现key中带"-"的配置使用此方式覆盖失败。

复现

通过如下步骤可以复现:

期望
配置应该被覆盖为true

截图

如果可以,附上截图来描述你的问题
1

额外的细节和日志

  • 版本:
  • 错误日志
  • 配置:
  • 平台和操作系统
    2
    3
    4
Copy link

dosubot bot commented Nov 6, 2023

🤖

Hello @ZeroSong211,

I'm Dosu, a bot here at the apollo repository. I'm capable of helping you solve bugs, answer questions, and even guide you to become a contributor. While you wait for a human maintainer, I'm here to assist you.

Rest assured, I'm currently reviewing your issue and will provide you with a comprehensive response shortly.

Copy link

dosubot bot commented Nov 6, 2023

🤖

根据我在Apollo仓库中的查找,我没有找到关于环境变量覆盖配置时,键中包含"-"字符会失败的相关信息。Apollo配置管理系统通过在属性文件中使用占位符来处理环境变量。这些占位符由${<variable_name>}语法表示。

例如,在提供的上下文中,dev.meta=${dev_meta}意味着在运行时,dev.meta属性将被dev_meta环境变量的值替换。

这允许Apollo根据其运行的环境动态调整其配置,无需更改代码或重新编译应用程序。你可以在这个链接中查看相关的代码:apollo-portal/src/main/resources/apollo-env.properties

关于你提到的问题,我建议你提供更多的信息,例如你的环境变量和配置的具体情况,以及你在尝试覆盖配置时遇到的具体错误。这将有助于我更好地理解和解答你的问题。

Sources


This response is meant to be useful and save you time. It is not meant to be a precise solution, but rather a starting point for your own research.

Help me be more useful! Please leave a 👍 if this is helpful and 👎 if it is irrelevant.

If you want to continue the conversation, start your reply with @dosu-bot.

@ZeroSong211
Copy link
Author

不是同一种情况,还请人工帮忙看一下,感谢~

Copy link

dosubot bot commented Nov 6, 2023

@nobodyiam, I could use your expertise on this one.

@ZeroSong211
Copy link
Author

ZeroSong211 commented Nov 6, 2023

经过多次测试,不是带"-"的key覆盖失败,而是key-value左右值不相等才会覆盖失败,改成如下图格式后,环境变量是可以进行覆盖的(ps:也就是说想要用环境变量去覆盖apollo的配置,就必须保持key-value左右值相等。。)。
image

@nobodyiam
Copy link
Member

@ZeroSong211 这个是 spring 自身的配置规则,简而言之 test.param.enable-test 等同于环境变量 TEST_PARAM_ENABLE_TEST,两个都是 KEY,不是 value。

@ZeroSong211
Copy link
Author

TEST_PARAM_ENABLE_TEST打错了吧。。应该是TEST_PARAM_ENABLE-TEST

Copy link

stale bot commented Dec 9, 2023

This issue has been automatically marked as stale because it has not had activity in the last 30 days. It will be closed in 7 days unless it is tagged "help wanted" or other activity occurs. Thank you for your contributions.

@stale stale bot added the stale label Dec 9, 2023
Copy link

stale bot commented Dec 16, 2023

This issue has been automatically closed because it has not had activity in the last 7 days. If this issue is still valid, please ping a maintainer and ask them to label it as "help wanted". Thank you for your contributions.

@stale stale bot closed this as completed Dec 16, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants