title: Bean not autowiring from a different package
body: <p>I have a configuration class. In that configuration class I am creating a bean of type <code>RestTemplate</code>. This configuraration class resides in <code>com.example.Config</code>.</p>
  
  <p>I have a <code>Controller</code> in the package located in <code>com.example.Controller</code>.</p>
  
  <p>In my <code>Main</code> class (which resides in <code>com.example.Core</code>), I have the following:</p>
  
  <pre class="lang-java prettyprint-override"><code>@SpringBootApplication(scanBasePackages = {"com.example.Config", "com.example.Controller"})
  @EnableDiscoveryClient
  public class Main {
      public static void main(String[] args) {
          SpringApplication.run(Main.class, args);
      }
  }
  </code></pre>
  
  <p>I am trying to autowire the <code>RestTemplate</code> bean in my <code>Controller</code> but upon starting my app I get the following error:</p>
  
  <pre><code>Field `restTemplate` in `com.example.Controller.HelloWebClientController` required a bean of type `org.springframework.web.client.RestTemplate` that could not be found.
  - User-defined bean method `restTemplate` in `RestConfig`
  
  Action:
  
  Consider revisiting the entries above or defining a bean of type `org.springframework.web.client.RestTemplate` in your configuration.
  </code></pre>
  
  <p>This is my config class:</p>
  
  <pre class="lang-java prettyprint-override"><code>@Configuration
  public class RestConfig {
  
      @Bean
      public RestTemplate restTemplate(){
          return new RestTemplate();
      }
  }
  </code></pre>