title: How to signal Spring that Bean property must be populated?
body: <p>Let's say that I have a Java class like this:</p>
  
  <pre><code>public class PersonGrabber {
    private PersonDAO dao;
  
    public void setDao(PersonDao dao) {
      this.dao = dao;
    }
    public PersonDAO getDao() {
      return this.dao;
    }
    //...
  }
  </code></pre>
  
  <p>And I have a corresponding Spring bean like this:</p>
  
  <pre><code>&lt;bean id="personGrabber" class="com.stackoverflow.example.PersonGrabber"&gt;
    &lt;property name="dao"&gt;&lt;null/&gt;&lt;/property&gt;
  &lt;/bean&gt;
  </code></pre>
  
  <p>Now, this is bad because I really need the <code>dao</code> property to be set to something on that bean before it becomes useful. However, I don't wanna wait till runtime to wait for it to throw a <code>NullPointerException</code>. Is there anyway to tell Spring that a bean property <strong>MUST</strong> be populated before it can be used? Ideally, I'd like it to crash on initialization so that I don't have to wait for it to find out. </p>
  
  <p>I was hoping for something like an annotation along the lines of:</p>
  
  <pre><code>public class PersonGrabber {
    @SpringRequired
    private PersonDAO dao;
    //...
  }
  </code></pre>
  
  <p>Any help from some Spring veterans out there? </p>