Announcement Announcement Module
Collapse
No announcement yet.
How to set a list value element from a property placeholder? Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • How to set a list value element from a property placeholder?

    Spring version: 2.5.6.A

    I have a setter/getter that is a list of strings and I want to set the value element from a property placeholder.

    Java:
    Code:
    public class MyClass
    {
    	private List<String> myList;
    	public void setMyList(List<String> myList) {
    		this.myList = myList;
    	}
    
    	public List<String> getMyList() {
    		return myList;
    	}
    }
    Bean config:
    Code:
    <bean id="propertyConfigurer" class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
    		<property name="location">
    			<value>classpath:my-properties.txt</value>
    		</property>
    </bean>		
    
    <bean id="myClass" class="com.myCompany.MyClass">
    	<property name="myList">
    		<list>
    			<value>${my.property}</value>
    		</list>
    	</property>
    </bean>
    Property file:
    Code:
    my.property=foo
    The problem is that ${my.property} is not resolved as "foo".
    The class receives the literal value "${my.property}".

  • #2
    Nevermind...

    Strange. After waiting a while it works like it should.

    Comment

    Working...
    X