playframeworkplayframework-2.0sbtjvm-argumentstypesafe-stack

How to use play framework config library command line parameters in non play application


In play application I can add command line parameters to override default config in resourses:

... -Dconfig.file=/opt/conf/prod.conf

I develop non-play application with play config library and generate jar with sbt-assembly.

Upd
I want use command line params:

java -jar my-app.jar -Dconfig.file=/opt/conf/prod.conf

but there is no effect. I load config with:

ConfigFactory.load()

Should I manually resolve cmd params and load file into config?


Solution

  • I found mistake:

    -Dconfig.file is a system parameter. System parameters should be written before -jar. Other way they are interpreted as command line parameters. So correct solution:

    java -Dconfig.file=/opt/conf/prod.conf -jar my-app.jar