title: Spring bean prevent instantiation and use intended implementation
body: <p>Given that I have two implementation of a Processor interface:</p>
  <p>One Synchronous:</p>
  <pre><code>@Service(&quot;Synchronous&quot;)
  @Primary
  public class SyncProcessor implements Processor { ... }
  </code></pre>
  <p>Other Async:</p>
  <pre><code>@Service(&quot;Asynchronous&quot;)
  public class AsynchronousProcessor implements Processor { ... }
  </code></pre>
  <p>The class that uses these services:</p>
  <pre><code>public class TestController{
  
      private final Processor processor;
  
      public TestController(final Processorprocessor) {
          this.processo r= processor;
      }
  
  }
  </code></pre>
  <p>These services and the controller class sit in a common library framework maven project (say project A) and they get injected as dependencies in other projects (e.g. project B &amp; C).</p>
  <p>I want project B &amp; C to use SyncProcessor by default which it does since it is annotated with @Primary.</p>
  <p>However, the async service gets also instantiated and I would like to prevent that.</p>
  <p>It should only be instantiated when in the projects B and C I do the following:</p>
  <pre><code>@Bean(&quot;customAsync&quot;)
  public Processor processor(MyRepo repo,
                                     JobRunner jobRunner) {
      return new AsynchronousProcessor (repo, jobRunner);
  }
  </code></pre>
  <p>The problem I am currently having is AsyncProcessor instance is getting created multiple times. How can I prevent this from happening?</p>
  <p>The other issue I am having is that even when I create the bean in project B, the synchronous bean is being called. How can I use async?</p>