Hi,
I want to be able to override bean config properties with system properties.
For example,
is the default and I want that to remain as is. I'd like to be able to start my JVM withCode:<bean id="myObject" parent="_abstractObject"> <property name="jndiName" value="my.jndi.Name"/> </bean>I tried, I guess I can't. Looking at the PropertyOverrideConfigurer JavaDoc I see no system override property.Code:-DmyObject.jndiName=my.new.jndi.Name
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
and then if there are no system properties everything works and if there is aCode:<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 myfile.properties containsCode:-Doverride.properties=myfile.properties
and the override properties get loaded then I am happy enough.Code:myObject.jndiName=my.new.jndi.Name
But I get the following exception
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?Code:Could not resolve placeholder 'override.properties'
Cheers in advance
Russell


Reply With Quote