How can I specify a different config file for testing in Play 2.1

前端 未结 4 1483
误落风尘
误落风尘 2021-02-02 17:06

I would like to define different database connections for multiple test environments(Production, Staging, Development). After reading the post \"How do I specify a config file w

4条回答
  •  天命终不由人
    2021-02-02 18:02

    You can run your application from console with alternative config file, anyway you need to use -Dconfig.file with full path as there are some problems ... that I can't realize with other option. For an example in unix env:

    play -Dconfig.file=/home/akkie/play/some-project/conf/local_akkie_dev.conf "~run 9123"
    

    Of course for easier launching you can create bash script for calling this line.

    Edit: Note that you don't need to write whole config in each additional config file, as you can just include your main config at beginning and then overwrite only required properties :

    include "application.conf"
    
    key.to.override=blah
    

    Take a look to the official doc

提交回复
热议问题