title: How to exclude package in given runtime profile in Spring Boot application
body: <p>In my application I have two profiles <code>dev</code> and <code>prod</code>, I can exclude beans using <code>org.springframework.context.annotation.Profile</code> annotation:</p>
  
  <pre><code>package com.example.prod;
  
  @Service
  @Profile("prod")
  public class MyService implements MyBaseService {}
  </code></pre>
  
  <p>The problem is, I have several beans which are annotated in such way, all of them are in same package <code>com.example.prod</code>. Similar structure exists for <code>dev</code> profile (<code>com.example.dev</code> package), and may in future I will have some additional profiles. Is there possibility to exclude whole package at once? I tried to play with <code>org.springframework.context.annotation.ComponentScan</code>, but I was unable to add exclude filters depends on actual profile, I wonder if there is easy way to solve my problem.</p>