title: Spring boot ConditionalOnBean annotation
body: <p>There are spring boot 2.0.2 configuration</p>
  
  <pre><code>@Configuration
  public class ApiConfig {
  
      @Bean
      @Profile("!tests")
      @ConditionalOnProperty(name = "enabled", havingValue = "true")
      public MyService service() {
          return new MyServiceImpl();
      }
  
  }
  </code></pre>
  
  <p>... and some controller which should be created and added to application context only if MyService bean is initialized.</p>
  
  <pre><code>@RestController
  @ConditionalOnBean(MyService.class)
  public class MyController {
     @Autowired
     private MyService service;
  }
  </code></pre>
  
  <p>It works Ok. But occasionally spring boot skips MyController creating. According to the logs MyService is created, but after any other beans(including all controllers), at the end.</p>
  
  <p>Why boot does not process <code>@Configuration</code> beans prior to <code>@RestController</code>?
  Thanks.</p>