title: How to do Spring Lookup Method Injection with Annotations?
body: <p>Is there any way to use Lookup Method Injection using annotations?</p>
  
  <p>Given the following class:</p>
  
  <pre><code>@Service
  public abstract class A {
  
  
      protected abstract createB();
  
  }
  </code></pre>
  
  <p>In order to get it to work I have to declare in spring applicationContext.xml the following:</p>
  
  <pre><code>&lt;bean id="b" class="com.xyz.B"&gt;
  &lt;/bean&gt;
  
  &lt;bean id="a" class="com.xyz.A"&gt;
      &lt;lookup-method name="createB" bean="b"/&gt;
  &lt;/bean&gt;
  </code></pre>
  
  <p>Even though I am using <code>&lt;context:component-scan base&gt;</code> I have to declare it also in the XML. Not a good approach I think.</p>
  
  <p>How to do it with annotations?</p>