Scala actor的java.lang.NoSuchMethodError

编程入门 行业动态 更新时间:2024-10-10 06:16:19
本文介绍了Scala actor的java.lang.NoSuchMethodError的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我有一个简单的Scala应用程序(从此处获取),我想测试一下。 整个项目已使用SBT成功编译。但是,当我使用 sbt测试启动测试时,收到以下错误消息:

I have a simple Scala application (taken from here) which I want to test. The whole project is compiled successfully with SBT. However, when I launch the tests with sbt test I get the following error message:

Could not run test ConnectionTest:java.lang.NoSuchMethodError: akka.actor.Props$.apply(Lscala/Function0;)Lakka/actor/Props;

从互联网搜索中,我得到的印象是我的某些版本不兼容,但这仅仅是一个推测。 可能出什么问题了?

From the internet search, I get the impression that some of my versioning is not compatible but that is merely a guess. What may be wrong?

[测试用例]

import akka.actor.{Props, Actor, ActorSystem, ActorRef} import akka.testkit.{TestKit, TestActorRef, ImplicitSender} import org.scalatest.{WordSpecLike, BeforeAndAfterAll} import org.scalatest.matchers.MustMatchers class ConnectionTest extends TestKit(ActorSystem("ConnectionSpec")) with WordSpecLike with MustMatchers with BeforeAndAfterAll { override def afterAll() { system.shutdown() } "Server" must { "bind to port " in { // create server val server = system.actorOf(Props[Server], name = "server") expectMsg("Bound to /127.0.0.1:8888") } } }

[ build.sbt]

name := "MyApp" version := "0.2" scalaVersion := "2.10.4" mainClass := Some("akka.Main") resolvers += "Typesafe Repository" at "repo.typesafe/typesafe/releases/" libraryDependencies += "com.typesafe.akka" %% "akka-actor" % "2.3.2" libraryDependencies += "com.typesafe.akka" %% "akka-testkit" % "2.1.4" % "test" libraryDependencies += "org.scalatest" % "scalatest_2.10" % "2.0" % "test"

推荐答案

您需要使用相同版本的Akka进行测试。 / p>

You need to use the same version of Akka for testkit.

libraryDependencies += "com.typesafe.akka" %% "akka-testkit" % "2.1.4" % "test"

应该是

libraryDependencies += "com.typesafe.akka" %% "akka-testkit" % "2.3.2" % "test"

更多推荐

Scala actor的java.lang.NoSuchMethodError

本文发布于:2023-11-25 11:37:11,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1629590.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:actor   Scala   java   NoSuchMethodError   lang

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!