Properties component use system variables in locations failed

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

Properties component use system variables in locations failed

Mi Jane 米静
Dear community,

I’m trying to use system variables in Properties Component locations and it doesn’t work. Here is some details:


  1.  Spring beans:

<bean class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer" id="PropertyPlaceholder">

        <property name="locations">

            <list>

                <value>classpath:**/application.properties</value>

                <value>classpath:**/application-${spring.profiles.active}.properties</value>

            </list>

        </property>

</bean>

<bean class="org.apache.camel.component.properties.PropertiesComponent">

        <property name="location" value="classpath:application-${spring.profiles.active}.properties"/>

</bean>

  1.  Spring application.properties(as default value):

spring.profiles.active=local

  1.  VM options:
-Dspring.profiles.active=dev

I meant to use application-dev.properties. But actually camel used application-local.properties while spring used application-dev.properties.

My hope is to hear from anyone who can help to figure out what’s wrong.

My reference: https://camel.apache.org/manual/latest/using-propertyplaceholder.html#UsingPropertyPlaceholder-UsingSystemandEnvironmentVariablesinLocations




Regards,
Jane

Reply | Threaded
Open this post in threaded view
|

Re: Properties component use system variables in locations failed

Claus Ibsen-2
Hi

<bean class="org.apache.camel.component.properties.PropertiesComponent">
        <property name="location"
value="classpath:application-${spring.profiles.active}.properties"/>
</bean>

This above is Spring itself that setup this bean, its not something
Camel can do about. So that ${ } is resolved by Spring and somehow it
uses the value from the properties file and not the VM option.

Not sure how you bootstrap Spring and Camel but its more of a Spring
issue than Camel.

On Fri, Feb 14, 2020 at 11:17 AM Mi Jane 米静
<[hidden email]> wrote:

>
> Dear community,
>
> I’m trying to use system variables in Properties Component locations and it doesn’t work. Here is some details:
>
>
>   1.  Spring beans:
>
> <bean class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer" id="PropertyPlaceholder">
>
>         <property name="locations">
>
>             <list>
>
>                 <value>classpath:**/application.properties</value>
>
>                 <value>classpath:**/application-${spring.profiles.active}.properties</value>
>
>             </list>
>
>         </property>
>
> </bean>
>
> <bean class="org.apache.camel.component.properties.PropertiesComponent">
>
>         <property name="location" value="classpath:application-${spring.profiles.active}.properties"/>
>
> </bean>
>
>   1.  Spring application.properties(as default value):
>
> spring.profiles.active=local
>
>   1.  VM options:
> -Dspring.profiles.active=dev
>
> I meant to use application-dev.properties. But actually camel used application-local.properties while spring used application-dev.properties.
>
> My hope is to hear from anyone who can help to figure out what’s wrong.
>
> My reference: https://camel.apache.org/manual/latest/using-propertyplaceholder.html#UsingPropertyPlaceholder-UsingSystemandEnvironmentVariablesinLocations
>
>
>
>
> Regards,
> Jane
>


--
Claus Ibsen
-----------------
http://davsclaus.com @davsclaus
Camel in Action 2: https://www.manning.com/ibsen2