I want to use Spring RestTemplate
in Kotlin like this:
//import org.springframework.web.client.RestTemplate
fun findAllUsers(): List {
First, you will make a new class - UserList.kt (the name is our owner)
Inside:
class UserList : MutableList by ArrayList()
After that, you can call your method that has a RestTemplate
val response: List < Item > ? = restTemplate.getObject("yourEndpoint", UserList::class.java)
It may be returns null
, so you need to take care of that.