I have what I assume to be a common use case for developing and deploying a Play 2.3.6 application:
sbt run
and the application uses application.conf
as expected.sbt start
and specify the config file, production.conf
, which resides in the same directory as the dev config file (which is <project root>/conf/
)Following the instructions under the "Specifying alternative configuration file" heading on the official docs page, like so:
$ sbt start -Dconfig.file=/full/path/to/project/conf/production.conf
The application starts without error, but I can inspect the web application and see that it is loading my application.conf
development values, not my production values found in production.conf
.
I also tried the suggested approach:
$ sbt start -Dconfig.resource=production.conf
And the server fails to start with error:
[error] com.typesafe.config.ConfigException$IO: production.conf: java.io.IOException: resource not found on classpath: production.conf
Has anyone else figured out how to do this correctly?
If you need to open a CONF file, you can use TextMate in macOS or GNU Emacs in Linux. Some examples of configuration files include rc. conf for the system startup, syslog. conf for system logging, smb.
An application configuration file is an XML file used to control assembly binding. It can redirect an application from using one version of a side-by-side assembly to another version of the same assembly. This is called per-application configuration.
Creating a Typesafe Config With Fallbacks In this case, we first load our overrides. conf , then set a fallback of our defaults. conf from above. When searching for any property, it will first search the original config, then traverse down the fallbacks until a value is found.
Configurations from a file By default, the ConfigFactory looks for a configuration file called application. conf. If willing to use a different configuration file (e.g.: another. conf), we just need to indicate a different file name and path to load (e.g.: ConfigFactory.
After a few wasted hours, I figured it out. Using quotes as follows passes the parameter correctly:
$ sbt "start -Dconfig.resource=production.conf"
Also, if you need to specify the port number, make sure it comes after the config option, otherwise it will be ignored:
$ sbt "start -Dconfig.resource=production.conf 9001"
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With