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

  • property substitution with default doesn't work?

    So in the /etc/env-properties file, i have:


    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:systemPropertiesModeName="SYSTEM_PROPERTIES_MODE _OVERRIDE" >
    <property name="locations">

    <bean id="testit" class="java.lang.String">
    <constructor-arg index="0" value="${port}" />

    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}" />

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

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