簡體   English   中英

您如何覆蓋類型安全配置設置?

[英]How do you override Typesafe Config settings?

在我的 application.conf 文件中,我有類似的東西

platform3.operational.state = "development"

我運行我的服務

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

但是配置屬性還是“開發”

你如何覆蓋 typesafe-config 設置?

也許這個博客可以幫助你:

不幸的是 sbt run 不支持 java 系統屬性,因此在運行 sbt 時您無法使用命令行調整設置。 sbt-revolver 插件允許您在分叉的 JVM 中運行您的應用程序,它允許您使用命令行傳遞 java 參數。

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

來自 ConfigFactory.systemProperties() [ ConfigFactory.java ] 的 JavaDoc:

 * 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>

請注意中間的段落:“加載將包含系統屬性作為覆蓋,默認引用和默認覆蓋也將包含”。

當您直接執行時,它是否按預期工作?

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM