user3278612
user3278612

Reputation: 201

How to get environment variable in play scala Framework 2.5.0?

PFB the code which I used for getting environment variable but it is not working.

In application.conf

clientId = ${?clientId}

In Filters.scala

sys.env.get("clientId");

But it is "None".

If I type env in the respective environment, I could see the proper clientId which I set.

clientId = ba6ecff4-4aec-4298-8e98-f1f0b320249f

What is the right way to get the environment variable in Play Framework for scala 2.5.0?

Upvotes: 2

Views: 3313

Answers (1)

Andriy Kuba
Andriy Kuba

Reputation: 8263

You override the value. Change the property name

Correct:

myClientId = ${?clientId}

Wrong:

clientId = ${?clientId}

Documentation:

Because you can reference variables from within other variables, ensure you don’t name your environmental variable the same as the field name.

Upvotes: 2

Related Questions