我正在使用 Quarkus 和 Kotlin 构建一个 REST api。我试图通过使用 @PathParam 注释在我的函数中包含一个路径参数。这就是我所拥有的:
@GET
@Produces(MediaType.APPLICATION_JSON)
@Path("/{userId}")
fun getUser(@PathParam userId: UUID) : GetUserResponse =
try {
GetUserSuccess(userRepository.find("id", userId))
} catch (e: NotFoundException) {
GetUserFailure(e)
}
不幸的是,我收到一条错误消息,指出没有为参数值传递任何值。
我用谷歌搜索了一些东西,我发现的大部分内容都是关于错误的导入。我仔细检查了该部分,但我导入了正确的部分:import javax.ws.rs.*,其中还包括 PathParam。
有谁知道这有什么问题?