如何使用不属于库的本地环境变量?

问题描述 投票:0回答:1

我有一些依赖于环境的变量。它们不属于deps库,但我知道的唯一方法是将它们导入,就像它们一样。我在config.exs中导入它们,如下所示:

config :martin,
  url: "http://localhost:4001"

然后我在staging.exsprod.exs中定义了生产和分期的不同网址,它工作正常。

但是我对这个导入的每个变量都有这个警告

You have configured application :martin in your configuration
file, but the application is not available.

This usually means one of:

1. You have not added the application as a dependency in a mix.exs file.

2. You are configuring an application that does not really exist.

Please ensure :martin exists or remove the configuration.

有没有办法以更正确的方式做到这一点,不会触发警告?

environment-variables elixir
1个回答
3
投票

您可以使用应用的名称代替......

config :my_app,
  martin_url: "http://localhost:4001"
© www.soinside.com 2019 - 2024. All rights reserved.