Announcement Announcement Module
Collapse
No announcement yet.
Configuring a PropertyOverrideConfigurer from a PropertyPlaceholderProperty Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Configuring a PropertyOverrideConfigurer from a PropertyPlaceholderProperty

    Hi,
    I want to be able to override bean config properties with system properties.

    For example,

    Code:
     <bean id="myObject" parent="_abstractObject">
        <property name="jndiName" value="my.jndi.Name"/>
      </bean>
    is the default and I want that to remain as is. I'd like to be able to start my JVM with
    Code:
    -DmyObject.jndiName=my.new.jndi.Name
    I tried, I guess I can't. Looking at the PropertyOverrideConfigurer JavaDoc I see no system override property.

    So I am starting to convolute a way. Maybe I can have a bunch of different override property files and chose which one to load with a system property like

    Code:
    <bean class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer"   id="bootstrap" p:systemPropertiesModeName="SYSTEM_PROPERTIES_MODE_OVERRIDE">
            <property name='properties'>
                <props>
                	<prop key="override.properties">empty.properties</prop>
                </props>
            </property>
        </bean>
    
      <bean class="org.springframework.beans.factory.config.PropertyOverrideConfigurer" p:ignoreResourceNotFound="true"
            p:locations="classpath:${override.properties}"/>
    and then if there are no system properties everything works and if there is a

    Code:
    -Doverride.properties=myfile.properties
    and myfile.properties contains
    Code:
    myObject.jndiName=my.new.jndi.Name
    and the override properties get loaded then I am happy enough.

    But I get the following exception

    Code:
    Could not resolve placeholder 'override.properties'
    Is it possible to configure a PropertyOverrideConfigurer with a PropertyPlaceholderConfigurer? Or is there a best/normal/acceptable way to override properties based on some system property?

    Cheers in advance

    Russell
Working...
X