title: How to Configure Dependency Injection in a Library Project?
body: <h1>How to Configure Dependency Injection in a Library Project?</h1>
  
  <p>Let me illustrate this question with the following example.</p>
  
  <p><strong>Maven Library Project</strong></p>
  
  <p>ReservationAPI</p>
  
  <p>com.example.reservation-api</p>
  
  <p>This project contains a convenience class called <em>ReservationApiClient</em> which uses a RestTemplate (from the Spring Framework) for making HTTP calls.</p>
  
  <p>Is it possible to make the RestTemplate field @Autowired in this library project instead of instantiating it myself?</p>
  
  <p><strong>Maven Executable Project</strong></p>
  
  <p>org.company.application</p>
  
  <p>This project is a Spring Boot application and uses the above ReservationAPI as a dependency.  This app will create a @Bean for the convenience class <em>ReservationApiClient</em> contained in that library and will then execute its public methods which in turn make HTTP requests.</p>
  
  <p>What is a good strategy and/or best practices for the scenario described above?  </p>