title: How to @Autowire services in SpringBoot
body: <p>Good day, guys. I have a question about autowiring services into my classes when using Springboot. All of the examples I have seen on the Internet as well as in the Springboot specification do something of the like (taking an excerpt from the Springboot version 1.5.7 specification):</p>
  
  <pre><code>package com.example.service;
  import org.springframework.beans.factory.annotation.Autowired;
  import org.springframework.stereotype.Service;
  
  @Service
  public class DatabaseAccountService implements AccountService {
  private final RiskAssessor riskAssessor;
  
  @Autowired
  public DatabaseAccountService(RiskAssessor riskAssessor) {
  this.riskAssessor = riskAssessor;
  }
  // ...
  }
  </code></pre>
  
  <p>This is a class that injects a property through its constructor, by means of @Autowiring the constructor. Another form is to @Autowire the property like this:</p>
  
  <pre><code>@Autowired
  private final RiskAssessor riskAssessor
  </code></pre>
  
  <p>But, where I work, for these two methods to work, I have been told that I need to use this method:</p>
  
  <pre><code> applicationContext.getAutowireCapableBeanFactory().autowireBean(Object.class)
  </code></pre>
  
  <p>They have told me that I need this in order for the @Autowired annotation to work.</p>
  
  <p>Now my question to you is: why is there no simple annotation that allows the @Autowire to function correctly? (Something like @AutowiredClass). The above method is too verbose and hard to remember, so surely there must be a better way to make @Autowired work on classes in order to inject services, just like we do in Grails where we just say <code>def someService</code> and it is automatically injected.</p>