title: How to autowire a class with non-empty constructor?
body: <p>I'd like to <code>@Autowired</code> a class that has a non-empty constructor.
  Just the the following as an example, it does not necessairly have to be a view/service. Could be whatever component you like, having non-default constructor:</p>
  
  <pre><code>@Component
  class MyViewService {
    //the "datasource" to show in the view
    private List&lt;String&gt; companies companies;
    private MyObject obj;
  
    public MyViewService(List&lt;String&gt; companies, MyObject obj) {
      this.companies = companies;
      this.obj = obj;
    }
  }
  </code></pre>
  
  <p>Of course I cannot just write</p>
  
  <pre><code>@Autowired
  private MyViewService viewService;
  </code></pre>
  
  <p>as I'd like to use the constructor with the list. But how?</p>
  
  <p>Are there better approaches than refactoring these sort of constructors to <code>setters</code>? I wouldn't like this approach as ideally the constructor forces other classes to provide all objects that are needed within the service. If I use setters, one could easily forget to set certain objects.</p>