title: Spring @ConditionalOnBean in combination with @Component
body: <p>Having the next situation:</p>
  
  <pre class="lang-java prettyprint-override"><code>
  @ConditionalOnBean(ServiceD.class)
  @Component
  class ServiceAImpl implements ServiceA {
  
      private ServiceB serviceB;
      private ServiceC serviceC;
      private ServiceD serviceD;
  
      public ServiceA(ServiceB serviceB, ServiceC serviceC, ServiceD serviceD) {
          this.serviceB = serviceB;
          this.serviceC = serviceC;
          this.serviceD = serviceD;
      }
  }
  
  interface ServiceD {
  
      void doStuff();
  }
  
  @Component
  class ServiceDImpl implements ServiceD {
  
      private ServiceE serviceE;
  
      public ServiceD(ServiceE serviceE) {
          this.serviceE = serviceE;
      }
  
      @Override
      public void doStuff() {
          //...
      }
  }
  
  </code></pre>
  
  <p>I need serviceA to be loaded only if there exists a serviceD implementation.</p>
  
  <p>From <code>@ConditionalOnBean</code> documentation: <em>"The condition can only match the bean definitions that have been processed by the application context so far and, as such, it is strongly recommended to use this condition on auto-configuration classes only."</em>.</p>
  
  <p>My question is:
  As <strong>ServiceD</strong> is a dependency of <strong>ServiceA</strong>, will this guarantee that when <code>@ConditionalOnBean</code> is evaluated, <strong>ServiceD</strong> will be already processed by the application context?</p>
  
  <p>If not, is there any other way to acomplished that without using autoconfiguration classes?</p>