2014-11-07 98 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