Is there any way to substitute environment variables in playframework's application.conf?

后端 未结 3 1603
生来不讨喜
生来不讨喜 2021-02-05 15:30

Is there any way to use environment variables in the play! application.conf file? Something like this:

%prod.db.url=${env.DATABASE_JDBC_URL}
%prod.db.driver=org.         


        
3条回答
  •  独厮守ぢ
    2021-02-05 16:18

    I have the same problem. My solution :

    • let application.conf with only properties for local development and store it in a VCS (SVN, Git, ...) for your dev team
    • add a line in the application.conf file : "@include.prod=prod.conf"
    • the file prod.conf contains only %prod.* properties
    • create the file prod.conf directly on prod server (or store it in a different VCS than your application, where only allowed people can read/write it)

    It works fine for me.

    It just adds a message for the dev team when the application starts :

    ex: 20 mai 2011 21:09:16 play.Logger warn ATTENTION: Missing include: @include.prod

    Really not a problem. Just inform your dev team that this message is not a problem and to not delete the "@include.prod" line in application.conf

    Hope it helps

提交回复
热议问题