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?
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"
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.