我正在尝试为发布请求创建端点:
@Singleton
@Controller("/v1")
class Addr() {
@Post("/setAddress")
fun set(@Body body: RpcRequest<Address>) {
println(body.params.newAddress)
}
}
数据:
data class Address(val newAddress: String)
@JsonIgnoreProperties(ignoreUnknown = true)
data class RpcRequest<T>(
val method: String,
val params: T
)
但不幸的是,发生了错误:
java.util.LinkedHashMap cannot be cast to com.project.location.data.Address
好像Micronaut无法解析Address
内的RpcRequest
数据类吗?