Configuration depending on launch mode

后端 未结 3 574
忘掉有多难
忘掉有多难 2021-02-04 09:22

Play can be launched in dev mode (via run), in production mode (via start) or in test mode. Is there a way to provide a different config file (co

3条回答
  •  臣服心动
    2021-02-04 10:06

    You can set a different config file using one of the 3 ways play gives to you:

    1 - Using -Dconfig.resource

    It will search for an alternative configuration file in the application classpath (you usually provide these alternative configuration files into your application conf/ directory before packaging). Play will look into conf/ so you don’t have to add conf/.

    $ /path/to/bin/ -Dconfig.resource=prod.conf

    2 - Using -Dconfig.file

    You can also specify another local configuration file not packaged into the application artifacts:

    $ /path/to/bin/ -Dconfig.file=/opt/conf/prod.conf

    3 - Using -Dconfig.url

    You can also specify a configuration file to be loaded from any URL:

    $ /path/to/bin/ -Dconfig.url=http://conf.mycompany.com/conf/prod.conf

    Checkout more on:

    https://www.playframework.com/documentation/2.3.x/ProductionConfiguration

提交回复
热议问题