title: @ConditionalOnMissingBean and @ConditionalOnBean on the same type
body: <p>I've got strange situation. I'm trying to write auto configuration class where I create bean if another bean exists or not so I've got conditional on bean and conditional on missing bean on same type..</p>
  
  <p>Here is my code:</p>
  
  <pre><code>@Bean
  @ConditionalOnMissingBean(
      type = {"com.example.Api"}
  )
  public ApiManager apiManager() {
      return new ApiManager() {
          public Result getValue(Request request) {
              throw new Exception("Api not provided.");
          }
  
          public Result setValue(Request request) {
              throw new Exception("Api not provided.");
          }
      };
  }
  
  @Bean
  @ConditionalOnBean(
      type = {"com.example.Api"}
  )
  public ApiManager apiManager(Api api) {
      return new ApiManagerImpl(api);
  }
  </code></pre>
  
  <p>The problem is that it does not check <code>@ConditionalOnBean</code> if it already checked in <code>@ConditionalOnMissingBean</code> that bean of type <code>com.example.Api</code> is not missing and then bean is not created. </p>
  
  <p>And I get error like:</p>
  
  <pre><code>Parameter 2 of constructor in com.example.ServiceImpl required a bean of type 'com.example.ApiManager' that could not be found.
  - Bean method 'apiManager' in 'ApiAutoConfiguration' not loaded because @ConditionalOnMissingBean (types: com.example.Api; SearchStrategy: all) found bean 'api'
  - Bean method 'apiManager' in 'ApiAutoConfiguration' not loaded because @ConditionalOnMissingBean (types: com.example.Api; SearchStrategy: all) found bean 'api'
  </code></pre>