pme*_*pme 2 scala typesafe-config
我有一个核心库,将其配置设置为系统属性。
mail.from = mail@example.com
Run Code Online (Sandbox Code Playgroud)
我想用它们覆盖我的配置,例如:
my.mail.from = "me@example.com"
my.mail.from = ${?mail.from}
Run Code Online (Sandbox Code Playgroud)
这适用于单元测试。在我的 Play (2.6) 应用程序中,它没有。
PropertiesConfiguration.init() // this inits the system properties
info("mail.from: " + sys.props.get("mail.from")) // >> 'mail@example.com' as expected
val config = ConfigFactory.load()
info("my.mail.from: " + config.getString("my.mail.from")) // >> 'me@example.com' instead of 'mail@example.com'
Run Code Online (Sandbox Code Playgroud)
这是不可能的还是我错过了什么?
尝试使任何缓存配置无效以获取对系统属性的更改:
PropertiesConfiguration.init()
info("mail.from: " + sys.props.get("mail.from"))
ConfigFactory.invalidateCaches()
val config = ConfigFactory.load()
info("my.mail.from: " + config.getString("my.mail.from"))
Run Code Online (Sandbox Code Playgroud)