0

How can I define a Spring bean in an xml config file matching this attribute ?

private List<String[]> durations;

I've different things, but none of them seems to work - I'm getting exception from the parser.

Thank you !

2
  • 2
    What did you try that isn't working, and what version of Spring? Commented Oct 26, 2011 at 15:03
  • Sorry guys I've been away for a long time ! I'm not anymore on this project but I'll try what you've told me and let you know. Thanks anyway for the answer. Commented Jan 19, 2012 at 9:42

3 Answers 3

1

You could try a <list> in <list> in the spring application context. A <list> is converted by spring to either a real java.util.List or an array.

    <property name="durations">
        <list>
            <list>
                <value>abc</value>
                <value>def</value>
            </list>
            <list>
                <value>abc2</value>
                <value>def2</value>
            </list>
        </list>
    </property>
Sign up to request clarification or add additional context in comments.

Comments

1

Try this:

    <bean name="test" class="Test">
    <property name="values" value="hugo,emil"/>
</bean>

Spring should carryout the conversion for you if you seperate the values with comma's.

values is a String[] array

Comments

0

Try without generic type : private List durations;

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.