0
我寫使用下面的代碼http4s客戶端庫http4s客戶字符串創建開放的
import org.http4s.UrlForm
import org.http4s.Uri
import org.http4s.client.blaze.SimpleHttp1Client
import org.http4s.dsl._
import org.http4s.client._
val requestUrl = s"$url/foo/bar"
val client = SimpleHttp1Client()
val uri = Uri.fromString(requestUrl).valueOr(throw _)
val req = POST(uri, UrlForm("name" -> "foo"))
val result = client.expect[String](req).run
println(result)
但這變得異常
[error] Exception in thread "main" java.lang.NoSuchMethodError: scalaz.syntax.std.package$option$.ToOptionIdOps(Ljava/lang/Object;)Lscalaz/syntax/std/OptionIdOps;
[error] at org.http4s.parser.Rfc3986Parser$class.HierPart(Rfc3986Parser.scala:33)
[error] at org.http4s.parser.RequestUriParser.HierPart(RequestUriParser.scala:9)
[error] at org.http4s.parser.Rfc3986Parser$class.AbsoluteUri(Rfc3986Parser.scala:21)
[error] at org.http4s.parser.RequestUriParser.AbsoluteUri(RequestUriParser.scala:9)
[error] at org.http4s.parser.Rfc3986Parser$class.Uri(Rfc3986Parser.scala:18)
我SBT依賴是
libraryDependencies ++= Seq(
"org.http4s" % "http4s-core_2.11" % "0.15.3"
"org.http4s" % "http4s-blaze-client_2.11" % "0.15.3"
"org.http4s" %% "http4s-argonaut" % "0.15.3"
"org.http4s" % "http4s-dsl_2.11" % "0.15.3"
"org.http4s" %% "http4s-client" % "0.15.3"
)
非常感謝。根據你的矩陣。我將版本升級到0.15.3a,並解決了問題。 –