You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tamaya.apache.org by "P. Ottlinger" <po...@apache.org> on 2017/05/30 22:37:49 UTC

conceptual question: overriding configuration values? properties in JAR vs. environment variables

Hi,

my pet project is an executable JAR that uses tamaya to read its
configuration from a properties file.

Due to the fact that this property file is in a shaded JAR I'd ike to
override certain properties (=paths to data files needed in the
application).

If my javaconfiguration.properties file contains
foopath=/foo/bar.csv
can I override it via a -Dfoopath=mypath/bar.csv when running my FatJAR?
or does this functionality not yet exist?

Due to build problems on Travis I'm still with 0.2-incubating.

Thanks for a hint ;-)

Phil

Re: conceptual question: overriding configuration values? properties in JAR vs. environment variables

Posted by "P. Ottlinger" <po...@apache.org>.
Am 31.05.2017 um 23:16 schrieb Anatole Tresch:
> is there a tamaya.ordinal entry in your config resource? or passed as
> -Dtamaya.ordinal=123
> ???
All is good - the problem was in my way of launching the app.

It's easy to externally overwrite the config key such as:

export foo=bar; java -jar fatJar.jar
or
java -Dfoo=bar -jar fatJar.jar

Thanks, Anatole for pointing me to my mistake!

Cheers & happy weekend,
Phil


Re: conceptual question: overriding configuration values? properties in JAR vs. environment variables

Posted by Anatole Tresch <at...@gmail.com>.
is there a tamaya.ordinal entry in your config resource? or passed as
-Dtamaya.ordinal=123
???

Am 31.05.2017 23:14 schrieb "Anatole Tresch" <at...@gmail.com>:

> hi Phil
> can you do a hangout tomorrow? sharing your screen would be simpler so I
> can see what is happening....
> wdyt?
> J Anatole
>
> Am 31.05.2017 23:10 schrieb "P. Ottlinger" <po...@apache.org>:
>
>> Hi,
>>
>> I digged further today ...
>>
>> Am 31.05.2017 um 00:50 schrieb P. Ottlinger:
>> > Is there a name prefix since -Dfoopath=bar does not change anything,
>> > the value from inside the jar wins.
>>
>> from my IDE I was able to set a parameter that was used from inside the
>> application, but when I produce a shaded JAR the overwirte does not seem
>> to work, yet.
>>
>> Thanks,
>> Phil
>>
>>

Re: conceptual question: overriding configuration values? properties in JAR vs. environment variables

Posted by Anatole Tresch <at...@gmail.com>.
hi Phil
can you do a hangout tomorrow? sharing your screen would be simpler so I
can see what is happening....
wdyt?
J Anatole

Am 31.05.2017 23:10 schrieb "P. Ottlinger" <po...@apache.org>:

> Hi,
>
> I digged further today ...
>
> Am 31.05.2017 um 00:50 schrieb P. Ottlinger:
> > Is there a name prefix since -Dfoopath=bar does not change anything,
> > the value from inside the jar wins.
>
> from my IDE I was able to set a parameter that was used from inside the
> application, but when I produce a shaded JAR the overwirte does not seem
> to work, yet.
>
> Thanks,
> Phil
>
>

Re: conceptual question: overriding configuration values? properties in JAR vs. environment variables

Posted by "P. Ottlinger" <po...@apache.org>.
Hi,

I digged further today ...

Am 31.05.2017 um 00:50 schrieb P. Ottlinger:
> Is there a name prefix since -Dfoopath=bar does not change anything,
> the value from inside the jar wins.

from my IDE I was able to set a parameter that was used from inside the
application, but when I produce a shaded JAR the overwirte does not seem
to work, yet.

Thanks,
Phil


Re: conceptual question: overriding configuration values? properties in JAR vs. environment variables

Posted by "P. Ottlinger" <po...@apache.org>.
Hi Anatole,

Am 31.05.2017 um 00:42 schrieb Anatole Tresch:
> by default this should be the case since the SystemPropertiesPropertySource
> has higher ordinal than the JavaConfigurationPropertySoiurce (names could
> be different)...

mmmh - alright.

Is there a name prefix since -Dfoopath=bar does not change anything,
the value from inside the jar wins.

You are right, there is a PropertiesSource available .... maybe it needs
a readable toString() since its a default Object#toString() right now in
the log upon application startup.

Thanks + n8
Phil

Re: conceptual question: overriding configuration values? properties in JAR vs. environment variables

Posted by Anatole Tresch <at...@gmail.com>.
Hi Phil,

by default this should be the case since the SystemPropertiesPropertySource
has higher ordinal than the JavaConfigurationPropertySoiurce (names could
be different)...

With 3.0-incubating environment properties by default also override system
properties, since this is the default mechanism used for docker container
configuration. More options to think about when combining with Kubernetes
features such as secrets and configmaps...

J Anatole

2017-05-31 0:37 GMT+02:00 P. Ottlinger <po...@apache.org>:

> Hi,
>
> my pet project is an executable JAR that uses tamaya to read its
> configuration from a properties file.
>
> Due to the fact that this property file is in a shaded JAR I'd ike to
> override certain properties (=paths to data files needed in the
> application).
>
> If my javaconfiguration.properties file contains
> foopath=/foo/bar.csv
> can I override it via a -Dfoopath=mypath/bar.csv when running my FatJAR?
> or does this functionality not yet exist?
>
> Due to build problems on Travis I'm still with 0.2-incubating.
>
> Thanks for a hint ;-)
>
> Phil
>



-- 
*Anatole Tresch*
PPMC Member Apache Tamaya
JCP Star Spec Lead
*Switzerland, Europe Zurich, GMT+1*
*maketechsimple.wordpress.com <http://maketechsimple.wordpress.com/> *
*Twitter:  @atsticks, @tamayaconf*

  [image: GeeCON] [image: JSD_Speaker_2017]