I’m extending a Java class in Kotlin, but want to ...
# getting-started
j
I’m extending a Java class in Kotlin, but want to add a constructor so that I can get rid of all the lateinit @autowires.
Copy code
open class EmailProcessor : AbstractRPCConsumer<EmailRequest, EmailResponse>() {
    @Autowired
    internal lateinit var template: AmqpTemplate

    @Autowired
    internal lateinit var mapper: ObjectMapper
If I do this:
Copy code
open class EmailProcessor @Autowired constructor(template: AmqpTemplate, mapper: ObjectMapper) : AbstractRPCConsumer<EmailRequest, EmailResponse>() {

    override fun toJson(request: EmailResponse) = mapper.writeValueAsString(request)
then I get
Unresolved reference mapper
Any idea how I should do this?