title: Java Spring IOC constructor-arg inject a List<Integer>
body: <p>i am trying to develop a <code>Spring bean</code> like this</p>
  
  <pre><code>&lt;bean id="id" class="java.util.ArrayList" scope='prototype'&gt;
      &lt;constructor-arg&gt;
          &lt;list&gt;
              &lt;bean class='MyClass'&gt;
                  &lt;property name='id' value='1313'/&gt;
                  &lt;property name="name" value='John Lennon'/&gt;
                  &lt;property name='wifes'&gt;                        
                      &lt;list&gt;
                          &lt;bean class="WifeClazz"&gt;
                              &lt;constructor-arg index='0' value='Cynthia Lennon'/&gt;
                              &lt;constructor-arg index='1'&gt;                                    
                                  &lt;list&gt;&lt;value&gt;1962&lt;/value&gt;&lt;value&gt;1968&lt;/value&gt;&lt;/list&gt;
                              &lt;/constructor-arg&gt;
                          &lt;/bean&gt;                 
                      &lt;/list&gt;                 
                  &lt;/property&gt;
              &lt;/bean&gt;             
          &lt;/list&gt;
      &lt;/constructor-arg&gt;
  &lt;/bean&gt;        
  </code></pre>
  
  <p>this is just a example the <code>WifeClazz</code> the name is just for the example.. have a Constructor which have a String and a series of Integers.. <code>like this example</code></p>
  
  <pre><code>new WifeClazz("Cinthia Lennon",java.util.Arrays.asList(1,2,3,4,5,6,7,8));
  </code></pre>
  
  <p>the integers may be a severals from 1 to 10 integers.</p>
  
  <p>but i think is kind of annoying do something like this</p>
  
  <pre><code>&lt;constructor-arg index='1'&gt;                                    
        &lt;list&gt;
            &lt;value&gt;1&lt;/value&gt;
            &lt;value&gt;2&lt;/value&gt;
            &lt;value&gt;3&lt;/value&gt;
            &lt;value&gt;4&lt;/value&gt; 
        &lt;/list&gt;
   &lt;/constructor-arg&gt;
  </code></pre>
  
  <p>would be great if i could do something like this</p>
  
  <pre><code>  &lt;constructor-arg index='1'&gt;
         &lt;value&gt;#{T(java.util.Arrays).asList(1,2,3,4)}&lt;/value&gt;
    &lt;/constructor-arg&gt;
  </code></pre>
  
  <p>but throws Exception any clue?</p>
  
  <p>any help is hugely appreciate.</p>
  
  <p><strong>UPDATE</strong></p>
  
  <p>I have change my code according Edwin a something like this.</p>
  
  <pre><code>&lt;constructor-arg index="1" type="java.util.Collection" value="#{T(java.util.Arrays).asList(1,2,3,4,5)}"/&gt;
  </code></pre>
  
  <p>but throws </p>
  
  <pre><code>Caused by: java.lang.IllegalArgumentException: Final expected argument should be array type (the varargs parameter)
  </code></pre>
  
  <p>my target clazz is</p>
  
  <pre><code>public MyClass(final String name,final List&lt;Integer&gt;years){}
  </code></pre>
  
  <p>my resulting code</p>
  
  <pre><code>&lt;bean id="id" class="java.util.ArrayList" scope='prototype'&gt;
  &lt;constructor-arg&gt;
      &lt;list&gt;
          &lt;bean class='MyClass'&gt;
              &lt;property name='id' value='1313'/&gt;
              &lt;property name="name" value='John Lennon'/&gt;
              &lt;property name='wifes'&gt;                        
                  &lt;list&gt;
                      &lt;bean class="WifeClazz"&gt;
                          &lt;constructor-arg index='0' value='Cynthia Lennon'/&gt;
                          &lt;constructor-arg index="1" type="java.util.Collection" value="#{T(java.util.Arrays).asList(1,2,3,4,5)}"/&gt;
                      &lt;/bean&gt;                 
                  &lt;/list&gt;                 
              &lt;/property&gt;
          &lt;/bean&gt;             
      &lt;/list&gt;
  &lt;/constructor-arg&gt;
  &lt;/bean&gt;        
  </code></pre>
  
  <p>this solves the trick...</p>
  
  <pre><code>&lt;constructor-arg index='1' type="java.util.List" value="#{{1,2,3,4,5}}"/&gt;
  </code></pre>