title: Scala instance variable initialization using Spring annotation
body: <p>I find myself doing a lot of the following, where Spring fills in the value for HttpClient, <strong>correctly</strong>, upon package scanning.</p>
  
  <pre><code>@Resource(name = "httpClient")
  val httpClient: CloseableHttpClient = null// &lt;-- NAGS ME
  </code></pre>
  
  <p>That said, the code looks like it's cheating. On one hand a <code>null</code> is assigned, however at runtime, the correct value magically appears. </p>
  
  <p>I can make it a <code>var</code>but it really does not change during the lifetime of the instance once it's initialized. </p>
  
  <p>I am new to Scala, so first off, am I doing something totally off? If so what would you suggest as ways to do the elegantly and without being too wordy?</p>
  
  <p>Here are the alternatives I can think of</p>
  
  <ol>
  <li><p>Use constructor injection where possible. My issue here is that the constructor gets lost in all the annotation.</p></li>
  <li><p>Use an <code>@Configuration</code> bean and configure. This lacks the nice correlation that the <code>@Resource</code> annotation brings.</p></li>
  </ol>
  
  <p>Any suggestions?</p>
  
  <p>Thanks all in anticipation.</p>