title: How can I disable creating bean with @Component annotation in Spring?
body: <p>I have some common interface for refactoring logic in my project. It looks about like this:</p>
  <pre><code>public interface RefactorAwareEntryPoint {
  
      default boolean doRefactor() {
          if (EventLogService.wasEvent(getEventType())) {
              return true;
          }
          boolean result = doRefactorInternal();
          if (result) {
              EventLogService.registerEvent(eventType);
          }
          return result;
      }
  
      String getEventType();
      
      boolean doRefactorInternal();
  }
  </code></pre>
  <p>And than, when I need to write some refactoring - I implement this interface with methods, mark class like <code>@Component</code>, and Spring in loop evaluate each interface implementation and register it in database.
  But we have a lot of refactors (every year - 200-300 new). It's hard to disable old implementations manualy, and we have a lot of beans in our spring-context.
  Can we do something, for example, use some annotation - which will disable component creation by some condition?</p>
  <p>For example:</p>
  <pre><code>@Component
  @Enabled(YEAR.2020)
  public class CustomRefactor implements RefactorAwareEntryPoint {
   // Code implementation
  }
  </code></pre>
  <p>And this annotation will work like this (a pseudocode):</p>
  <pre><code>if (YEAR.2020) {
    create bean -&gt; new CustomRefactor()
  }
  </code></pre>
  <p>And when it will be <code>YEAR.2021</code> - we will have no beans from <code>YEAR.2020</code> in spring-context.</p>