title: Convert Spring XML-based to Java-Based Configuration
body: <p>I try not to using any xml. </p>
  
  <pre><code>&lt;bean id="restTemplate" class="org.springframework.web.client.RestTemplate"&gt;
  
      &lt;property name="messageConverters"&gt;
          &lt;list&gt;
              &lt;bean class="org.springframework.http.converter.xml.MarshallingHttpMessageConverter"&gt;
                  &lt;property name="marshaller" ref="jaxbMarshaller"/&gt;
                  &lt;property name="unmarshaller" ref="jaxbMarshaller"/&gt;
              &lt;/bean&gt;
              &lt;bean class="org.springframework.http.converter.FormHttpMessageConverter"/&gt;
          &lt;/list&gt;
      &lt;/property&gt;
  &lt;/bean&gt;
  </code></pre>
  
  <p>like this one: convert to @Bean</p>
  
  <pre><code>@Bean
  public RestTemplate restTemplate() {
      RestTemplate restTemplate = new RestTemplate();
      List&lt;HttpMessageConverter&lt;?&gt;&gt; converters = new ArrayList&lt;HttpMessageConverter&lt;?&gt;&gt;();
  
      converters.add(marshallingMessageConverter());
      restTemplate.setMessageConverters(converters);
  
      return restTemplate;
  }
  </code></pre>
  
  <p>Problem here.</p>
  
  <pre><code>&lt;bean id="jaxbMarshaller" class="org.springframework.oxm.jaxb.Jaxb2Marshaller"&gt;
      &lt;property name="classesToBeBound"&gt;
          &lt;list&gt;
              &lt;value&gt;com.cloudlb.domain.User&lt;/value&gt;
          &lt;/list&gt;
      &lt;/property&gt;
  &lt;/bean&gt;
  </code></pre>
  
  <p>Try to convert "com.cloudlb.domain.User" into Class [] not thing work.</p>
  
  <pre><code>@Bean
  public MarshallingHttpMessageConverter marshallingMessageConverter() {
      Jaxb2Marshaller marshaller = new Jaxb2Marshaller();
  
      //
      List&lt;Class&lt;?&gt;&gt; listClass = new ArrayList&lt;Class&lt;?&gt;&gt;();
      listClass.add(User.class);
  
      marshaller.setClassesToBeBound((Class&lt;?&gt;[])listClass.toArray());
      // --------------------------------
  
      return new MarshallingHttpMessageConverter(marshaller, marshaller);
  }
  </code></pre>
  
  <p>Error: problem with casting.</p>
  
  <p>Thank you in advance.</p>