cfg4j / cfg4j

Modern configuration library for distributed apps written in Java.

Home Page:http://cfg4j.org

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

How to use with environment variables?

Paxa opened this issue · comments

Any documentation on how it maps env variables to config values?

I'm also confused when try to use environment variables

Documentation don't have any information about it.

At first I exported env var:

export MY_SERVICE_URI=http://localhost:9900/

Then try to use it...
There is my code snippet:

ConfigurationSource envSource = new EnvironmentVariablesConfigurationSource();
ConfigurationProvider provider = new ConfigurationProviderBuilder()
                .withConfigurationSource(envSource)
                .build();
provider.getProperty("my.service.uri", String.class); // then throws exception...

Hi @Paxa!
I was debugging and found env vars resolving are case sensitive.
For the example above it means MY_SERVICE_URI env will resolve as MY.SERVICE.URI .

THanks alot for explaining! Appreciate it

I was debugging and found env vars resolving are case sensitive.

I wish it was configurable