2017-07-13 112 views
0

我正在嘗試將akka-http導入到我的Scala項目中。我使用IntelliJ作爲IDE。以下是我的build.sbt出了什麼問題?

import sbt._ 

name := "hello" 

version := "1.0" 

scalaVersion := "2.12.1" 

libraryDependencies ++= Seq(
    "com.typesafe.akka" %% "akka-http-experimental" % "1.0", 
    "com.typesafe.akka" %% "akka-http-spray-json-experimental" % "1.0", 
    "com.typesafe.akka" %%"akka-http-testkit-experimental" % "1.0", 
    "org.scalatest" %% "scalatest" % "2.2.5" % "test" 
) 

這是我遇到的錯誤:

Error:Error while importing SBT project:<br/>...<br/><pre>[info] Resolving org.scala-sbt.ivy#ivy;2.3.0-sbt-48dd0744422128446aee9ac31aa356ee203cc9f4 ... 
[info] Resolving org.scala-sbt#test-interface;1.0 ... 
[info] Resolving com.jcraft#jsch;0.1.50 ... 
[info] Resolving org.scala-lang#scala-compiler;2.10.6 ... 
[info] Resolving jline#jline;2.14.3 ... 
[info] Resolving org.scala-sbt#compiler-ivy-integration;0.13.15 ... 
[info] Resolving org.scala-sbt#incremental-compiler;0.13.15 ... 
[info] Resolving org.scala-sbt#logic;0.13.15 ... 
[info] Resolving org.scala-sbt#main-settings;0.13.15 ... 
[trace] Stack trace suppressed: run 'last *:ssExtractDependencies' for the full output. 
[trace] Stack trace suppressed: run 'last *:update' for the full output. 
[error] (*:ssExtractDependencies) sbt.ResolveException: unresolved dependency: com.typesafe.akka#akka-http-experimental_2.12;1.0: not found 
[error] unresolved dependency: com.typesafe.akka#akka-http-spray-json-experimental_2.12;1.0: not found 
[error] unresolved dependency: com.typesafe.akka#akka-http-testkit-experimental_2.12;1.0: not found 
[error] unresolved dependency: org.scalatest#scalatest_2.12;2.2.5: not found 
[error] (*:update) sbt.ResolveException: unresolved dependency: com.typesafe.akka#akka-http-experimental_2.12;1.0: not found 
[error] unresolved dependency: com.typesafe.akka#akka-http-spray-json-experimental_2.12;1.0: not found 
[error] unresolved dependency: com.typesafe.akka#akka-http-testkit-experimental_2.12;1.0: not found 
[error] unresolved dependency: org.scalatest#scalatest_2.12;2.2.5: not found 
[error] Total time: 6 s, completed Jul 13, 2017 6:14:02 PM</pre><br/>See complete log in <a href="file:/home/invictus/.IdeaIC2017.1/system/log/sbt.last.log">file:/home/invictus/.IdeaIC2017.1/system/log/sbt.last.log 

回答

0

您正在使用這些庫的過時版本。 Akka HTTP不再是實驗性的,在撰寫本文時,最新版本是10.0.9。更新您的build.sbt

scalaVersion := "2.12.1" 

libraryDependencies ++= Seq(
    "com.typesafe.akka" %% "akka-http" % "10.0.9", 
    "com.typesafe.akka" %% "akka-http-spray-json" % "10.0.9", 
    "com.typesafe.akka" %%"akka-http-testkit" % "10.0.9", 
    "org.scalatest" %% "scalatest" % "3.0.3" % "test" 
) 

注意,對於ScalaTest,你如果你使用Scala的2.12升級到3.x