title: Create an annotation that has a specific @ConditionalOnProperty?
body: <p>My plan is to create an annotation that if I put that on a class, the class will be a bean only if the @ConditionalOnProperty is true.</p>
  <p>I have this:</p>
  <p><code>@ConditionalOnProperty(prefix = &quot;backend-auth&quot;, value = &quot;enabled&quot;, havingValue = &quot;true&quot;, matchIfMissing = false)</code></p>
  <p>I want to create some beans (controllers / services) only if the <code>backend-auth.enabled=true</code> exists in the <code>application.properties</code> file. Now at the moment I have this:</p>
  <pre><code>@RestController
  @ConditionalOnProperty(prefix = &quot;backend-auth&quot;, value = &quot;enabled&quot;, havingValue = &quot;true&quot;, matchIfMissing = false)
  public class FirstController {}
  
  @RestController
  @ConditionalOnProperty(prefix = &quot;backend-auth&quot;, value = &quot;enabled&quot;, havingValue = &quot;true&quot;, matchIfMissing = false)
  public class SecondController{}
  
  @Service
  @ConditionalOnProperty(prefix = &quot;backend-auth&quot;, value = &quot;enabled&quot;, havingValue = &quot;true&quot;, matchIfMissing = false)
  public class FirstService {}
  
  @Service
  @ConditionalOnProperty(prefix = &quot;backend-auth&quot;, value = &quot;enabled&quot;, havingValue = &quot;true&quot;, matchIfMissing = false)
  public class SecondService{}
  </code></pre>
  <p>As you can see I am reusing the <code>@ConditionalOnProperty</code> part and in case I want to change the <code>prefix</code>, <code>value</code> or <code>havingValue</code> values, then I have to change it at 4 places and it can be missed if not paying attention...</p>
  <p>I am thinking about creating an annotation that contains the <code>@ConditionalOnProperty</code> and use this custom annotation on my <code>FirstController</code>, <code>SecondController</code>, <code>FirstService</code>, <code>SecondService</code>.</p>
  <p>I want to end up with something like this:</p>
  <pre><code>@RestController
  @BackendAuthEnabled
  public class FirstController {}
  
  @RestController
  @BackendAuthEnabled
  public class SecondController{}
  
  @Service
  @BackendAuthEnabled
  public class FirstService {}
  
  @Service
  @BackendAuthEnabled
  public class SecondService{}
  </code></pre>