title: Spring Boot: How to include a configuration class that is not in my base package?
body: <p>I've got a fairly standard spring boot app which is built with gradle from several gradle modules. Here's the directory layout:</p>
  
  <pre><code> - root
     - serviceA
       - src/main/java
         - org.example.serviceA
           - ServiceAApplication.java
     - serviceB
     - serviceC
     - common
       - src/main/java
         - org.example.common
           - CommonSecurityConfiguration.java
  
  </code></pre>
  
  <p>What I would like to do is to <strong>include</strong> the <code>CommonSecurityConfiguration</code> class from the shared <code>common</code> module in <code>serviceA</code>. Note that <code>ServiceAApplication</code> and <code>CommonSecurityConfiguration</code> reside in <strong>different base packages</strong>.</p>
  
  <p>I tried to use <code>@Import(CommonSecurityConfiguration.class)</code> on my <code>ServiceAApplication</code>, but that had no observable effect at all.</p>
  
  <p>The only thing which worked was to annotate <code>ServiceAApplication</code> like so:</p>
  
  <pre><code>@SpringBootApplication(basePackages = { "org.example.serviceA", "org.example.common"})
  public class ServiceAApplication { ... }
  </code></pre>
  
  <p>This approach works, but seems very <strong>coarse grained</strong> to me - it will import each and every component and configuration it finds in <code>org.example.common</code>.</p>
  
  <p>Is there a better way to do this? Can I include individual classes into the component scan by listing them one by one?</p>