title: How to define a bean of String array in Spring (using XML configuration)
body: <p>I am trying to define a Spring bean of type <code>String[]</code> and now able to find a way to do so. Sample program is shown below:</p>
  
  <pre><code>@Component("sampleClass")
  public class SampleClass {
      @Value("#{someArrayId}")
      private String[] someArray;
  
      public void doWithArray() {
          System.out.println(Arrays.toString(someArray));
      }
  }
  </code></pre>
  
  <p><strong>Spring XML Configuration</strong></p>
  
  <pre><code>&lt;context:annotation-config /&gt;
  &lt;context:component-scan base-package="com.demo.spring" /&gt;
  
  &lt;util:list id="someArrayId"&gt;
      &lt;array&gt;
          &lt;value&gt;Tiger&lt;/value&gt;
          &lt;value&gt;Lion&lt;/value&gt;
      &lt;/array&gt;
  &lt;/util:list&gt;
  </code></pre>
  
  <p>When I am running the program, I get following exception:</p>
  
  <pre><code>Exception in thread "main" org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'sampleClass': Injection of autowired dependencies failed; nested exception is org.springframework.beans.factory.BeanCreationException: Could not autowire field: private java.lang.String[] com.demo.spring.SampleClass.someArray; nested exception is org.springframework.beans.ConversionNotSupportedException: Failed to convert value of type 'java.util.ArrayList' to required type 'java.lang.String[]'; nested exception is java.lang.IllegalStateException: Cannot convert value of type [java.lang.Object[]] to required type [java.lang.String]: no matching editors or conversion strategy found
  </code></pre>
  
  <p>I kind of understand what Spring is complaining, but I don't know how to fix it.</p>
  
  <p>Appreciate if anyone can help.</p>
  
  <p>Thanks, NN</p>