我遇到了一个问题,Retrofit库正在识别该方法,而不是它的注释。它正在报告上面标题中的错误消息。
(背景:我使用的是SBT和sbt-android-plugin和Retroef1.6.1)
我的代码是这样的:
private trait MyService {
@GET("/api/test")
def test(): Observable[Any]
}
object MyService {
private val restAdapter = new RestAdapter.Builder().setEndpoint("http://somewhere").build()
val service = restAdapter.create(classOf[MyService])
service.test().subscribe(/* you get the idea */) // This line throws a RuntimeException with message in title above
}有一个非常类似的例子分散在GitHub周围,显然来自反应原理课程,例如这里。我只想说,我的设置是一样的。
当我遍历RestMethodInfo.parseMethodAnnotations()时,requestMethod变量确实是空的,requestType是SIMPLE。如果我将@FormUrlEncoded注释添加到我的测试方法中,requestType仍然被设置为SIMPLE。
有什么可能导致这一切的想法吗?
发布于 2014-07-18 20:02:05
发布于 2016-03-08 13:38:19
在改造中:2.0.0库需要使用来自retrofit2的注释:
import retrofit2.http.Field;
import retrofit2.http.FormUrlEncoded;
import retrofit2.http.GET;而不是retrofit:
import retrofit.http.Field;
import retrofit.http.FormUrlEncoded;
import retrofit.http.GET;https://stackoverflow.com/questions/24830891
复制相似问题