2017-01-23 39 views
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" 
) 

回答

2

我給他們打掃一下:

libraryDependencies ++= Seq(
    "org.http4s" %% "http4s-core" % "0.15.3", 
    "org.http4s" %% "http4s-blaze-client" % "0.15.3", 
    "org.http4s" %% "http4s-argonaut" % "0.15.3", 
    "org.http4s" %% "http4s-dsl" % "0.15.3", 
    "org.http4s" %% "http4s-client" % "0.15.3" 
) 

scalaVersion := "2.11.8" 

我無法用它重現它。我會安裝https://github.com/jrudolph/sbt-dependency-graph,看看你有一些庫取決於scalaz 7.1/7.2 - here's the matrix

對於URI處理,有a tiny bit of doc

+0

非常感謝。根據你的矩陣。我將版本升級到0.15.3a,並解決了問題。 –