在Scalatest中找不到所需的类错误

问题描述

我正在尝试为akka HTTP路由编写scalatest。下面是我的代码 错误

未找到所需的类。这可能是由于您的运行路径错误。缺少课程:akka / testkit / package $ TestDuration $ java.lang.NoClassDefFoundError:akka / testkit / package $ TestDuration $

import akka.http.scaladsl.testkit.{RouteTestTimeout,ScalatestRouteTest}
import controller.HomeController.route
import org.scalatest.matchers.should.Matchers
import org.scalatest.wordspec.AnyWordSpec
import scala.concurrent.duration.DurationInt

class SetSpec extends AnyWordSpec with Matchers  with ScalatestRouteTest {
  "The service" should  {
    "return a greeting for GET requests to the root path" in {
      // tests:
      Get() ~> route ~> check {
        // parsing the reponse as a string and asserting
        responseAs[String] shouldEqual "Hello World!"
      }
    }
  }
  implicit val timeout = RouteTestTimeout(5.seconds)
}

我的Build.sbt看起来像这样

lazy val root = project in file(".")
libraryDependencies ++= Seq(
  "com.typesafe.akka" %% "akka-actor" % "2.6.8","com.typesafe.akka" %% "akka-stream" % "2.6.8","com.typesafe.akka" %% "akka-http" % "10.2.0","com.typesafe.slick" %% "slick" % "3.3.2","com.typesafe.slick" %% "slick-hikaricp" % "3.3.2","org.slf4j" % "slf4j-nop" % "1.6.6","org.scalatest" %% "scalatest" % "3.2.2" % Test,"MysqL" % "mysql-connector-java" % "8.0.21","com.typesafe.akka" %% "akka-http-testkit" % "10.2.0" % Test
)

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)