Announcement Announcement Module
Collapse
No announcement yet.
property substitution with default doesn't work? Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • 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, 03:32 PM.

  • #2
    I tested with <context: property-placeholder> and annotation style injection in Spring 3, the default works just fine.

    Comment

    Working...
    X