title: How can I exclude Spring beans scanned from a project's dependency?
body: <p>I have a Gradle-based project with two modules <code>mod1</code> and <code>mod2</code>. Both are Spring Boot projects. <code>mod1</code> has <code>mod2</code> as a dependency:</p>
  
  <pre><code>dependencies {
      compile project(':mod2')
      //more deps
  }
  </code></pre>
  
  <p>Both <code>mod1</code> and <code>mod2</code> classes base package is <code>com.project</code>. In <code>mod2</code>, I have some Spring MVC controllers under <code>com.project.controllers</code>, so when I start <code>mod1</code>, <code>mod2</code> controllers are registered in the Spring context.</p>
  
  <p>I want to avoid that.</p>
  
  <p>I have tried excluding them using <code>exclude</code> parameter of <code>@SpringBootApplication</code>, but it's not working (because they are inside another module/dependency and not in the project itself, I guess).</p>
  
  <p>Is it possible to exclude <code>mod2</code>'s <code>com.project.controllers</code> package somehow by Gradle configuration? </p>