title: Spring Autowired annotion of service is null
body: <p>I have RestController class that calls Presenter to get some data.</p>
  
  <pre><code>@RestController
  @RequestMapping(value="notes/api")
  public class NotesRestController {
  
      private GetAllNotesPresenter getAllNotesPresenter;
  
      @RequestMapping(value="/all")
      public List&lt;Note&gt; getAll() {
          getAllNotesPresenter = new GetAllNotesPresenterImpl();
          return getAllNotesPresenter.getAll();
      }
  }
  </code></pre>
  
  <p>Inside Presenter class I call DataSource (not Spring Repository, just DAO class).</p>
  
  <pre><code>public class GetAllNotesPresenterImpl implements GetAllNotesPresenter {
  
      private NotesDataSource dataSource;
      private NotesRepository repository;
  
      public GetAllNotesPresenterImpl() {
          dataSource = new DatabaseDataSource();
      }
  
      @Override
      public List&lt;Note&gt; getAll() {
          return dataSource.getAll();
      }
  }
  </code></pre>
  
  <p>Inside DataSource class I want to do @Autowire of Spring service, but I get <strong>null pointer exception.</strong> Service is always null.</p>
  
  <pre><code>@Component
  public class DatabaseDataSource implements NotesDataSource {
  
      @Autowired
      private NotesService notesService;
  
      public DatabaseDataSource() {
      }
  
      @Override
      public List&lt;Note&gt; getAll() {
          return notesService.getAll();
      }
  }
  </code></pre>