title: Create bean configured in external jar spring boot
body: <p>I created a jar which has the configuration for RestTemplate. For example,</p>
  <p>java-client jar:</p>
  <p>com.java.rest.client</p>
  <pre><code>@Configuration
  public class RestTemplateClient {
  
  public RestTemplateClient() {
  }
  
  @Bean(
      name = {&quot;restClient&quot;}
  )
  RestTemplate restTemplate() throws Exception {
      //HTTP configurations
  }
  }
  </code></pre>
  <p>I am using this jar in another spring boot application. I want to use the same restTemplate configuration available in the jar. But on Autowiring the restTemplate, it throws Null Pointer Exception.</p>
  <p>In the Sprint boot project..
  com.example.auth</p>
  <pre><code>@Service
  public class Auth {
  
  @Autowired
  @Qualifier(&quot;restClient&quot;)
  RestTemplate restTemplate;
  
  public void sampleMethod()
          throws ResourceAccessException, Exception {
      
      restTemplate.setErrorHandler(errorHandler); //throws NullPointerException
      HttpHeaders headers = createHttpHeaders();
      HttpEntity&lt;T&gt; entity = new HttpEntity&lt;T&gt;(data, headers);
  
      restTemplate.exchange(&quot;url&quot;,
              GET,
              entity,
              class);
    }
  }
  </code></pre>
  <p>I am new to Spring boot, can someone please guide?</p>