You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@camel.apache.org by Mi Jane 米静 <Ja...@universalbeijing.com> on 2020/02/14 03:57:04 UTC

Properties component use system variables in locations failed

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


Re: Properties component use system variables in locations failed

Posted by Claus Ibsen <cl...@gmail.com>.
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 米静
<Ja...@universalbeijing.com> 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