supaham
07/02/2016, 8:52 PMdata class Value(val id: Long, val quote: String)
data class Quote(val type: String, val value: Value)
@SpringBootApplication
open class WrestlerServer : CommandLineRunner {
companion object {
val log = LoggerFactory.getLogger(WrestlerServer::class.java)
@JvmStatic fun main(args: Array<String>) {
SpringApplication.run(WrestlerServer::class.java, *args)
}
}
@Bean
open fun kotlinModule() = KotlinModule()
override fun run(vararg args: String?) {
var restTemplate = RestTemplate()
val quote = restTemplate.getForObject("<http://gturnquist-quoters.cfapps.io/api/random>", Quote::class.java)
<http://log.info|log.info>(quote.toString())
}
}
but it throws
Caused by: com.fasterxml.jackson.databind.JsonMappingException: No suitable constructor found for type [simple type, class com.supaham.wrestler.server.Quote]: can not instantiate from JSON object (missing default constructor or creator, or perhaps need to add/enable type information?)
at [Source: java.io.PushbackInputStream@1f193686; line: 1, column: 2]