In Gradle, we add the following dependencies:
dependencies {
compile("com.fasterxml.jackson.module:jackson-module-kotlin:$jackson_version")
compile("org.jetbrains.kotlin:kotlin-reflect:$kotlin_version"
}
Enable the Kotlin module in the Application.kt file:
@ApplicationPath("home")
class Application :MyApp(){
private val classes = setOf(PersonService: :class.java)
private val singletons = setOf(ContextResolver())
override fun getClasses() = classes
override fun getSingletons() = singletons
}
class ContextResolver :ContextResolver<ObjectMapper> {
val objectMapper = ObjectMapper()
init{
objectMapper.registerModule(KotlinModule())
}
override fun getContext(p0:Class<*>?) = objectMapper
}
The frameworks and their configurations offer loose coupling, dependency injections, and so on. We can use Kotlin compiler plugins to take advantage of the benefits that these frameworks provide. This reduces the number of classes that have to be modified.