title: How do I use setter injection with java configuration in Spring?
body: <p>I am trying to learn about setter injection in a SpringMVC web application, all of the examples I can find, show using <code>xml</code>. However, I was told that xml is deprecated and all new applications should be done with java configuration. Is this wrong, should I be using xml to configure my application?</p>
  
  <p>Where should I be declaring the bean and how would I do it?</p>
  
  <p>This is one of the examples I have seen, yet it is implemented with xml.</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt;
  &lt;beans xmlns="http://www.springframework.org/schema/beans"
     xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
     xsi:schemaLocation="http://www.springframework.org/schema/beans 
                         http://www.springframework.org/schema/beans/spring-beans.xsd"&gt;
  
    &lt;bean id="message"
        class="org.springbyexample.di.xml.SetterMessage"&gt;
      &lt;property name="message" value="Spring is fun." /&gt;
    &lt;/bean&gt;
  
  &lt;/beans&gt;
  </code></pre>