Spring - Need to autowire @RestController class in a @Component class
<p>I have combination of web and core projects under the same maven parent module as like,</p>

<p>Parent 
 - Web (com.parent.test.web)
 - Core (com.parent.test.core)</p>

<p>I would like to refer the web module dependency in the core project to invoke some of the api from web module</p>

<p>Web project sample,</p>

<pre><code>com.test.parent.web

public interface RestInterface {
    public ResponseEntity load();
}

@RestController
public class RestInterfaceImpl implements RestInterface {

    @Override
    @RequestMapping(value = "/getData", method = RequestMethod.GET, produces = APPLICATION_JSON)
    public @ResponseBody ResponseEntity&lt;Object&gt; load() {

    }
}
</code></pre>

<p>Core project sample,</p>

<pre><code>com.test.parent.core

@Component
public class CoreImpl implements CoreInterface {

    // Is this possible to autowire
    @Autowired
    private RestInterface restInterface;

    public boolean getOptions() {
        ResponseEntity&lt;Object&gt; results = restInterface.load();
        for (Object o : results) {
            //TODO
        }
    }
}
</code></pre>

<p>Because the projects are developed within the same parent pom module. All the projects will be grouped into a springboot jar and will be deployed into the same environment. So, I'd like to refer the web project dependency into the core project and trying to scan the web classes inside the core project.</p>

<p>I'd like to get clarified on few things ,</p>

<ul>
<li>Is it the good approach ?</li>
<li>If it is the good approach, how we can implement ?</li>
<li>If not then what will be correct approach ?</li>
</ul>