title: Spring Boot @Autowired with Kotlin in @Service is always null
body: <p>Currently I try to rewrite my Java Spring Boot Application with Kotlin. I encountered a problem that in all of my classes which are annotated with <code>@Service</code> the dependency injection is not working correctly (all instances are <code>null</code>). Here is an example:</p>
  
  <pre><code>@Service
  @Transactional
  open class UserServiceController @Autowired constructor(val dsl: DSLContext, val teamService: TeamService) {
    //dsl and teamService are null in all methods
  }
  </code></pre>
  
  <p>Doing the same in Java works without any problems:</p>
  
  <pre><code>@Service
  @Transactional
  public class UserServiceController
  {
      private DSLContext dsl;
      private TeamService teamService;
  
      @Autowired
      public UserServiceController(DSLContext dsl,
                               TeamService teamService)
      {
          this.dsl = dsl;
          this.teamService = teamService;
      }
  </code></pre>
  
  <p>If I annotate the component with <code>@Component</code> in Kotlin everything works fine:</p>
  
  <pre><code>@Component
  open class UserServiceController @Autowired constructor(val dsl: DSLContext, val teamService: TeamService) {
    //dsl and teamService are injected properly
  }
  </code></pre>
  
  <p>Google provided many different approaches for Kotlin and <code>@Autowired</code> which I tried but all resulted in the same <code>NullPointerException</code>
  I would like to know what the difference between Kotlin and Java is and how I can fix this?</p>