简体   繁体   English

您如何覆盖类型安全配置设置?

[英]How do you override Typesafe Config settings?

In my application.conf file I have something like在我的 application.conf 文件中,我有类似的东西

platform3.operational.state = "development"

I run my service with我运行我的服务

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

But the configuration property is still "development"但是配置属性还是“开发”

How do you override typesafe-config settings?你如何覆盖 typesafe-config 设置?

Maybe this blog helps you:也许这个博客可以帮助你:

Unfortunately sbt run doesn't support java system properties so you can't tweak settings with the command line when running sbt.不幸的是 sbt run 不支持 java 系统属性,因此在运行 sbt 时您无法使用命令行调整设置。 The sbt-revolver plugin, which allows you to run your app in a forked JVM, does allow you to pass java arguments using the command line. sbt-revolver 插件允许您在分叉的 JVM 中运行您的应用程序,它允许您使用命令行传递 java 参数。

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

From JavaDoc of ConfigFactory.systemProperties() [ ConfigFactory.java ]:来自 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>

Note the middle paragraph: "load will include the system properties as override already, as will defaultReference and defaultOverrides".请注意中间的段落:“加载将包含系统属性作为覆盖,默认引用和默认覆盖也将包含”。

Does it work as expected when you execute directly?当您直接执行时,它是否按预期工作?

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM