2014-11-07 94 views
0

在我application.conf文件我有类似如何覆盖Typesafe Config设置?

platform3.operational.state = "development" 

我跑我的服务与

sbt "project p3-s-sink" "run -Dplatform3.operational.state=test" 

但配置属性仍然是“发展”

你如何重写typesafe-配置设置?

回答

0

从ConfigFactory.systemProperties的JavaDoc的()[ConfigFactory.java]:

* Gets a <code>Config</code> containing the system properties from 
* {@link java.lang.System#getProperties()}, parsed and converted as with 
* {@link #parseProperties}. 
* <p> 
* This method can return a global immutable singleton, so it's preferred 
* over parsing system properties yourself. 
* <p> 
* {@link #load} will include the system properties as overrides already, as 
* will {@link #defaultReference} and {@link #defaultOverrides}. 
* 
* <p> 
* Because this returns a singleton, it will not notice changes to system 
* properties made after the first time this method is called. Use 
* {@link #invalidateCaches()} to force the singleton to reload if you 
* modify system properties. 
* 
* @return system properties parsed into a <code>Config</code> 

注中间段: “负载将包括系统属性重写已经,如将defaultReference和defaultOverrides”。

当您直接执行时是否按预期工作?

0

或许这个博客可以帮助你:

不幸的是SBT运行不支持Java系统属性,以便运行SBT当你不能使用命令行调整设置。 sbt-revolver插件允许您在分叉的JVM中运行您的应用程序,它允许您使用命令行传递java参数。

http://blog.michaelhamrah.com/2014/02/leveraging-typesafes-config-library-across-environments/

+0

虽然此链接可以回答这个问题,最好是在这里有答案的主要部件,并提供链接以供参考。如果链接页面更改,则仅链接答案可能会失效 – abarisone 2015-04-08 09:13:17