java多参数,在Javax WS上没有注释错误,当我使用“suspend”时,如何处理?
我正在使用Kotlin和javax创建一个非常基本的控制器。ws和翻新库
我创建了一个这样的控制器
@POST
@Consumes(MediaType.APPLICATION_JSON)
@Produces(MediaType.APPLICATION_JSON)
suspend fun sayHello(request: StudentRequest): StudentResponse {
这基本上需要另一种服务
但当我运行应用程序时,我会出现以下错误:
[FATAL] Method public final java.lang.Object MyResource.sayHello(StudentRequest,kotlin.coroutines.Continuation) on resource class MyResource contains multiple parameters with no annotation. Unable to resolve the injection source.;
handlerConstructors=[org.glassfish.jersey.server.model.HandlerConstructor@a0bf272]},
definitionMethod=public final java.lang.Object my.org.package.MyResource(sayHello,k**otlin.coroutines.Continuation**),
奇怪的是,有两个类似的帖子Jersey @PathParam : contains multiple parameters with no annotation
How can I pass multiple parameter to restful webservice using http post
https://github.com/dropwizard/dropwizard/issues/1115
但它们不一样,因为我的问题在于我的参数
我的身体要求没有缺失的标签,我基本上不知道在这一点上要寻找什么,知道这有什么问题吗
调试后,我注意到,当删除“suspend”时,有两个参数,一个是我的,另一个是Kotlin注入的,一切正常,但我无法进行异步调用
# 1 楼答案
要从阻塞代码中使用协同路由,需要使用协同路由生成器(例如^{} 或^{} )
不幸的是,在这种情况下,您不能仅仅将glassfish控制器标记为可暂停函数,因为框架不知道如何处理延续