1

I have application.conf

{
 name {
   postgres {
      host = ""
      username = ""
      password = ""
            }
     }
}

And I want to add my local.conf

{
 name {
   postgres {
      host = "blabla"
      username = "aa"
      password = "bb"
            }
     }
}

name.postgres.host.override = "" - doesn't work

  • How are you loading your `local.conf`at runtime? Like this? `$ /path/to/bin/ -Dconfig.resource=local.conf` – jacks Aug 01 '18 at 12:09
  • @Nio i just put it into app/conf/local.conf. ANd I need to have my local.conf inside my project tree – Timofey Gusev Aug 01 '18 at 12:13
  • Hi, have a read of the docs - https://www.playframework.com/documentation/2.6.x/ConfigFile#Configuration-file-syntax-and-features Play wont just load any xxx.conf, it just loads - by convention - `application.conf`. You can specify custom conf files but you need to tell Play what it needs to load at runtime. See these resources - https://www.playframework.com/documentation/2.6.x/ConfigFile#Specifying-an-alternative-configuration-file, https://stackoverflow.com/questions/40998441/play-how-to-use-different-configuration-files-for-dev-prod/40998985#40998985 – jacks Aug 01 '18 at 12:22
  • Why can't you use the `conf` directory? – jacks Aug 01 '18 at 12:26
  • 1
    @Nio I find answer by use custom settings reader. Cant use conf direct, couz my app conf is on git, and my local is just local) – Timofey Gusev Aug 01 '18 at 14:26

2 Answers2

2

In your application.conf, it will remain the same:

{
 name {
   postgres {
      host = ""
      username = ""
      password = ""
            }
     }
}

And in your local.conf, you should include application.conf like this:

include "application.conf"

{
 name {
   postgres {
      host = "blabla"
      username = "aa"
      password = "bb"
            }
     }
}

When running the sbt you should specifically mention to load local.conf like this (Or else application.conf will get loaded by default):

sbt run -Dconfig.resource=local.conf

With that, local.conf will be extended from application.conf. The value from local.conf will be picked if there is any key that is exists in both files.

Now, you would get:

name.postgres.host=blabla
hong823
  • 21
  • 4
0

you can include a conf file in a another conf file like this :

Screen

this will automatically override variables.

amezdari
  • 13
  • 3