title: How to replace a ConditionalOnMissingBean bean?
body: <p>I use a library which contains</p>
  <pre><code>public class MyFilter extends FilterParent { ... }
  </code></pre>
  <p>and</p>
  <pre><code>@Configuration
  public class AutoConf
  {
      @Bean
      @ConditionalOnMissingBean(FilterParent.class)
      public MyFilter myFilter ()
      {
          return new MyFilter (); //               &lt;------- I want to replace this
      }
  }
  </code></pre>
  <p>which loads correctly. I cannot change this library but I want to load a different filter bean</p>
  <p>I tried</p>
  <pre><code>@Component
  public class MyNewFilter extends MyFilter { ... }
  </code></pre>
  <p>and modified the application class</p>
  <pre><code>@SpringBootApplication
  public class Application
  {
      public static void main (String[] args)
      {
          SpringApplication.run (Application.class, args);
      }
  
      @Bean
      public CommandLineRunner commandLineRunner (ApplicationContext ctx)
      {
          return args -&gt; {
              // startup code
          };
      }
  
      @Bean
      public MyFilter myFilter ()
      {
          return new MyNewFilter (); //          &lt;----------- THIS IS NEW
      }
  }
  </code></pre>
  <p>But I still get <code>MyFilter</code> loaded instead of a <code>MyNewFilter</code>.</p>
  <p>How can I load a <code>MyNewFilter</code> bean instead of the <code>MyFilter</code> bean loaded by <code>AutoConf</code>, without changing <code>AutoConf</code>?</p>