如何在application.conf中读取数组环境变量?

时间:2016-03-14 12:34:24

标签: scala

我想在application.conf中定义一个变量,它将是一个字符串列表。目前在application.conf中我有这样的东西:

some.env.variable = ["a", "b"]

我试过了:

some.env.variable = ${?I_AM_ENV}.split(",")

当I_AM_ENV = a,b
时 但它没有用

加载应用时收到错误:

Wrong value type at 'some.env.variable', expecting: list but got: string

2 个答案:

答案 0 :(得分:1)

根据documentation

// in your env
export OPTIONAL_A='"b", "c"'

// in application.conf
path = [ "a", ${?OPTIONAL_A} ]

应评估path["a", "b", "c"]

答案 1 :(得分:0)

花点时间,但我们找到了。

application.conf

    access-control-allow-origin = ["http://localhost:4444"]
    access-control-allow-origin = ${?CLIENT_DOMAIN}
    export CLIENT_DOMAIN.0=http://localhost:3000
    export CLIENT_DOMAIN.1=http://localhost:3001