什么地方出了错?

What went wrong?

我正在尝试将 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

这些库似乎不适用于 Scala 2.12:

https://mvnrepository.com/search?q=akka+http+experimental

您使用的是这些库的过时版本。 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