title: SpringBoot doesn't recognize RestController from another module in multi module Java application
body: <p>I've spent quite some time but I can't get past this (configuration) issue. </p>
  
  <p><strong>Technology stack :</strong> Java (1.8), Springboot (starter-parent, starter-web), Maven, IntelliJ IDEA</p>
  
  <p><strong>Description:</strong> Trying to create a multi module Java application composed (at first) of 2 modules : </p>
  
  <ol>
  <li><strong>core</strong> module : main module (main business logic, every other module should see and interact through this one). This module contains the main application class.</li>
  <li><strong>webgateway</strong> module : Simple Rest Controller that will map a request and make calls to the <strong>core</strong> module </li>
  </ol>
  
  <p><strong>Issue:</strong> Springboot doesn't load/scan the RestController from the webgateway module => 404 error when sending the http request</p>
  
  <p><strong>Github repo</strong> : <a href="https://github.com/Sorin-J/Greeter" rel="noreferrer">https://github.com/Sorin-J/Greeter</a></p>
  
  <p><strong>Project configuration :</strong> </p>
  
  <pre><code>Greeter 
     |
     + pom.xml (parent pom)
     |
     + -- core                                            
     |     |
     |     + ...
     |     |
     |     + pom.xml
     |
     + -- webgateway 
           |
           + ...
           |
           + pom.xml (depends on core pom.xml)
  </code></pre>
  
  <p><strong>Parent pom.xml :</strong> </p>
  
  <pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt;
  &lt;project xmlns="http://maven.apache.org/POM/4.0.0"
           xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
           xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"&gt;
  
      &lt;modelVersion&gt;4.0.0&lt;/modelVersion&gt;
  
      &lt;groupId&gt;com.bet.jbs&lt;/groupId&gt;
      &lt;artifactId&gt;Greeter&lt;/artifactId&gt;
      &lt;packaging&gt;pom&lt;/packaging&gt;
      &lt;version&gt;1.0-SNAPSHOT&lt;/version&gt;
  
      &lt;modules&gt;
          &lt;module&gt;core&lt;/module&gt;
          &lt;module&gt;webgateway&lt;/module&gt;
      &lt;/modules&gt;
  
      &lt;parent&gt;
          &lt;groupId&gt;org.springframework.boot&lt;/groupId&gt;
          &lt;artifactId&gt;spring-boot-starter-parent&lt;/artifactId&gt;
          &lt;version&gt;1.3.3.RELEASE&lt;/version&gt;
      &lt;/parent&gt;
  
      &lt;dependencies&gt;
          &lt;dependency&gt;
              &lt;groupId&gt;org.springframework.boot&lt;/groupId&gt;
              &lt;artifactId&gt;spring-boot-starter-web&lt;/artifactId&gt;
          &lt;/dependency&gt;
      &lt;/dependencies&gt;
  &lt;/project&gt;
  </code></pre>
  
  <p><strong>core</strong> module pom.xml :           </p>
  
  <pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt;
  &lt;project xmlns="http://maven.apache.org/POM/4.0.0"
           xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
           xsi:schemaLocation="http://maven.apache.org/POM/4.0.0   http://maven.apache.org/xsd/maven-4.0.0.xsd"&gt;
  
      &lt;parent&gt;
          &lt;artifactId&gt;Greeter&lt;/artifactId&gt;
          &lt;groupId&gt;com.bet.jbs&lt;/groupId&gt;
          &lt;version&gt;1.0-SNAPSHOT&lt;/version&gt;
      &lt;/parent&gt;
  
      &lt;modelVersion&gt;4.0.0&lt;/modelVersion&gt;
  
      &lt;artifactId&gt;core&lt;/artifactId&gt;
  
  &lt;/project&gt;
  </code></pre>
  
  <p><strong>webgateway</strong> module pom.xml : </p>
  
  <pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt;
  &lt;project xmlns="http://maven.apache.org/POM/4.0.0"
       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
       xsi:schemaLocation="http://maven.apache.org/POM/4.0.0  http://maven.apache.org/xsd/maven-4.0.0.xsd"&gt;
  
      &lt;parent&gt;
          &lt;artifactId&gt;Greeter&lt;/artifactId&gt;
          &lt;groupId&gt;com.bet.jbs&lt;/groupId&gt;
          &lt;version&gt;1.0-SNAPSHOT&lt;/version&gt;
      &lt;/parent&gt;
  
      &lt;modelVersion&gt;4.0.0&lt;/modelVersion&gt;
  
      &lt;artifactId&gt;webgateway&lt;/artifactId&gt;
  
      &lt;dependencies&gt;
          &lt;dependency&gt;
              &lt;groupId&gt;com.bet.jbs&lt;/groupId&gt;
              &lt;artifactId&gt;core&lt;/artifactId&gt;
              &lt;version&gt;1.0-SNAPSHOT&lt;/version&gt;
          &lt;/dependency&gt;
      &lt;/dependencies&gt;
  &lt;/project&gt;
  </code></pre>
  
  <p><strong>MainApplication</strong> class from <strong>core</strong> module : </p>
  
  <pre><code>package com.bet.jbs.core;
  
  import org.springframework.boot.SpringApplication;
  import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
  import org.springframework.context.annotation.ComponentScan;
  import org.springframework.context.annotation.Configuration;
  
  @Configuration
  @ComponentScan(basePackages = {"com.bet.jbs.core", "com.bet.jbs.webgateway"})
  @EnableAutoConfiguration
  public class MainApplication {
  
      public static void main(String[] args) throws Exception {
          SpringApplication.run(MainApplication.class, args);
      }
  }
  </code></pre>
  
  <p><strong>GreetingController</strong> class from <strong>webgateway</strong> module :</p>
  
  <pre><code>package com.bet.jbs.webgateway.controller;
  
  import com.bet.jbs.core.util.GreetingGenerator;
  import org.springframework.web.bind.annotation.RequestMapping;
  import org.springframework.web.bind.annotation.RequestMethod;
  import org.springframework.web.bind.annotation.RestController;
  
  @RestController
  public class GreetingController {
  
      @RequestMapping(value = "/webgreeting", method = RequestMethod.GET)
      public String getGreeting() {
          return "WEBGATEWAY module says " + GreetingGenerator.getRandomGreeting();
      }
  }
  </code></pre>
  
  <p>Just to test that an identical REST controller would work fine if it is located in the <strong>core</strong> module, I've created a similar <strong>GreetingController</strong> class also in <strong>core</strong> module (and this one works fine) :</p>
  
  <pre><code>package com.bet.jbs.core.controller;
  
  import com.bet.jbs.core.util.GreetingGenerator;
  import org.springframework.web.bind.annotation.RequestMapping;
  import org.springframework.web.bind.annotation.RequestMethod;
  import org.springframework.web.bind.annotation.RestController;
  /*
   * This REST controller should not be in the CORE component.
   * It is just for proving that this controller is recognized and the other one from WEBGATEWAY component is not.
   *
   */
  @RestController
  public class GreetingController {
  
      @RequestMapping(value = "/coregreeting", method = RequestMethod.GET)
      public String getGreeting() {
          return "CORE module says " + GreetingGenerator.getRandomGreeting();
      }
  }
  </code></pre>