Domanda

I want to tokenize a few keys in my application.conf file to use variables from another properties file. How can I do so? Here is an example.

my-play-project/conf/application.conf db.default.url=${env.db.url} db.default.driver=${env.db.driver} db.default.user=${env.db.user} db.default.pass=${env.db.password}

my-play-project/conf/env/devlab/project.properties db.url=myoracleserver.lab.org:1521 db.driver=oracle.thin db.user=myname db.password=mypassword

my-play-project/conf/env/devlab2/project.properties db.url=myoracleserver2.lab.org:1521 db.driver=oracle.thin db.user=myname db.password=mypassword

Q. Is there a way to set devlab/project.properties to be part of system resolvable properties?

È stato utile?

Soluzione

Play's configuration uses Typesafe Config. There are several ways of combining configuration together on the classpath and at runtime.

  • Creating multiple application.conf and application.properties files and putting them all on the classpath (i.e. in different JARs). The configuration will be combined. See Standard Behavior.
  • Using includes to pull in files with different names.
  • Using substitutions to pull in values from other config files.
  • Using substitutions to pull in environment variables or system properties.
Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top