-
Oct 31st, 2012, 03:28 PM
#1
property substitution with default doesn't work?
So in the /etc/env-properties file, i have:
port=1234
And the substitution in the "testit" bean works fine. Ie, i end up with 1234 in my "testit" bean.
<!-- use placeholders where we might want a JVM argument -->
<bean id="propertyPlaceholder"
class="org.springframework.beans.factory.config.Pr opertyPlaceholderConfigurer"
p:ignoreResourceNotFound="true"
p:systemPropertiesModeName="SYSTEM_PROPERTIES_MODE _OVERRIDE" >
<property name="locations">
<list>
<value>file:/etc/env-overrides.properties</value>
</list>
</property>
</bean>
<bean id="testit" class="java.lang.String">
<constructor-arg index="0" value="${port}" />
</bean>
However, if i change the bean def to use a default value:
<bean id="testit" class="java.lang.String">
<constructor-arg index="0" value="${port:666}" />
</bean>
I end up with port set to 666, instead of 1234. Of course, the intent is to use 666 if nothing is found in the property file. But i do have "port" defined in the property file, but i end up with the default of 666.
How is this defaulting supposed to work?
Last edited by tunkul; Oct 31st, 2012 at 03:32 PM.
-
Oct 31st, 2012, 08:31 PM
#2
I tested with <context: property-placeholder> and annotation style injection in Spring 3, the default works just fine.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules