Using the kotlin-spring plugin in Gradle

In Gradle, the kotlin-spring compiler plugin can be enabled by using buildscript with the allopen artifact, as shown here:

buildscript {   dependencies {   classpath "org.jetbrains.kotlin:kotlin-allopen:$kotlin_version"   } } apply plugin: "kotlin-spring"

Alternatively, the plugin can be enabled using plugins as follows:

plugins {   id "org.jetbrains.kotlin.plugin.spring" version "1.2.41" }

This plugin specifies the following annotations:

  • @Component
  • @Transactional
  • @Async
  • @Cacheable
  • @SpringBootTest

The classes that are annotated with these annotations are made open and accessible to the Spring framework so that we can create proxy objects. 

Get Kotlin for Enterprise Applications using Java EE now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.