Reputation: 2243
In my application.conf file I have something like
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?
Upvotes: 2
Views: 3418
Reputation: 14803
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. 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.
http://blog.michaelhamrah.com/2014/02/leveraging-typesafes-config-library-across-environments/
Upvotes: 2
Reputation: 1830
From JavaDoc of ConfigFactory.systemProperties() [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>
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?
Upvotes: 1