- android - RelativeLayout 背景可绘制重叠内容
- android - 如何链接 cpufeatures lib 以获取 native android 库?
- java - OnItemClickListener 不起作用,但 OnLongItemClickListener 在自定义 ListView 中起作用
- java - Android 文件转字符串
我正在 Scala 中使用 Rapture 构建 API,但无法解决隐式不在范围内的问题。这是我收到的错误的输出。
[error] /Users/Petesta/Documents/scala-project/src/main/scala/scala-project/main.scala:35: an implicit TimeSystem is required; please import timeSystems.numeric or timeSystems.javaUtil
[error] Error occurred in an application involving default arguments.
[error] val response = h.get()
[error] ^
[error] one error found
[error] (compile:compile) Compilation failed
[error] Total time: 5 s, completed Oct 16, 2014 3:36:10 PM
这是失败的代码。
def getUser(userName: String) = {
val h = Http / "some_url" / "user" / userName /? Map('key -> "value")
val response = h.get()
}
我不确定该怎么做,因为我已经尝试分别导入这两个库,但错误仍然相同。
我还添加了 -Xlog-implicits
标志来查看是否有其他原因导致了错误,但没有输出额外的信息。
有没有关于使用 rapture-net 库处理 HTTP 请求的好资源?除了 Jon Pretty 在 Scala By The Bay 的幻灯片外,我找不到其他的。我想不出一种方法将带有查询字符串的 url 传递到 rapture-uri,因为它希望函数调用看起来像这样 uri"url_dot_domain_with_query_strings".slurp[Char]
。
有什么想法吗?
最佳答案
在这种情况下,编译错误并不完全正确。您需要 2 个导入中的 1 个并且需要指定超时值。
def getUser(userName: String) = {
import timeSystems.numeric
val h = Http / "some_url" / "user" / userName /? Map('key -> "value")
val response = h.get(timeout = 5000L)
}
我真的不知道有什么好的资源,但您的基本单行代码是正确的。该库最大的问题实际上是有关所需导入的文档。但这是我发现对我有用的:
def getGoogle() = {
import rapture.codec._
import rapture.io._
import rapture.uri._
import rapture.net._
import encodings.`UTF-8`
uri"http://google.com".slurp[Char]
}
关于scala - 使用 Rapture Http 获取请求,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26415147/
我正在 Scala 中使用 Rapture 构建 API,但无法解决隐式不在范围内的问题。这是我收到的错误的输出。 [error] /Users/Petesta/Documents/scala-pro
所以,基本上我想创建一个 来自 base64 字符串内容的临时文件 .现在,我正在使用 native java-io 函数执行此操作。但我想使用 获得相同的结果用于 Scala 的 rapture-i
问题陈述:https://www.hackerrank.com/challenges/jack-goes-to-rapture 解决方案之一是使用修改后的 Dijkstra 算法。 原文: For a
我是一名优秀的程序员,十分优秀!