【发布时间】:2016-03-08 21:38:19
【问题描述】:
我遇到了一个问题,Retrofit 库正在识别方法而不是它的注释。它正在报告上面标题中的错误消息。
(背景:我将 SBT 与 sbt-android-plugin 和 Retrofit 1.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 上散布着一个非常相似的示例,显然来自响应式原理课程,例如here。可以这么说,我的设置是一样的。
当我单步执行RestMethodInfo.parseMethodAnnotations() 时,requestMethod 变量确实为空,requestType 为SIMPLE。如果我将@FormUrlEncoded 注释添加到我的测试方法中,requestType 仍然设置为SIMPLE。
关于什么可能导致这种情况的任何想法?
【问题讨论】:
标签: java android scala retrofit