How to specify a configuration file with sbt running in the Play application?

I have what I believe is a common use case for developing and deploying a Play 2.3.6 application:

  • In development, I run sbt run, and the application uses application.confas expected.
  • During the creation process, I would like to use sbt startand specify the configuration file production.conf, which is located in the same directory as the dev configuration file (which is located <project root>/conf/)

Following the instructions in the "Specifying an Alternate Configuration File" section of the official documentation page , complete the following steps:

$ sbt start -Dconfig.file=/full/path/to/project/conf/production.conf

The application starts without errors, but I can check the web application and see that it loads the development values application.conf, not my production values ​​found in production.conf.

I also tried the suggested approach:

$ sbt start -Dconfig.resource=production.conf

And the server does not start with an 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?

+4
source share
1 answer

After several hours wasted, I realized this. Using quotes as follows passes the parameter correctly:

$ sbt "start -Dconfig.resource=production.conf"

In addition, if you need to specify a port number, make sure that it appears after the configuration option, otherwise it will be ignored:

$ sbt "start -Dconfig.resource=production.conf 9001"
+11
source

All Articles