softshipper
softshipper

Reputation: 34071

How to setup configuration files environments?

I have the following environments:

  1. dev
  2. stage
  3. prod

Each environment will have different configuration and in akka documentation it says, that it is possible to include files.

Including files
Sometimes it can be useful to include another configuration file, for example if you have one application.conf with all environment independent settings and then override some settings for specific environments.

Specifying system property with -Dconfig.resource=/dev.conf will load the dev.conf file, which includes the application.conf

include "application"

akka {   loglevel = "DEBUG" }

My project environment looks as the following: enter image description here

When I do unit test, I would like to use dev.conf configuration file and I have to setup somehow, that it will take the dev.conf file.

As the doc says above:

Specifying system property with -Dconfig.resource=/dev.conf

It is not clear to me, how to do it. Where do I have to pass it?

The content of my dev.conf looks as the following:

include "application"

akka {loglevel = "DEBUG"}  

The question is, how to make sure, when the unit test is started, that the dev.conf file is going use?

Upvotes: 0

Views: 93

Answers (1)

houcros
houcros

Reputation: 1020

That's a parameter for the JVM. The -D option is used to pass key-value system properties.

I see you're using IntelliJ, so I assume you're running your tests directly in there. If that's the case, you can pass parameters to the JVM selecting: Run -> Edit Configurations... -> (Select your test) -> VM parameters. Just paste -Dconfig.resource=/dev.conf in there, save and run your test.

Upvotes: 2

Related Questions