问题描述
尝试运行我的项目时出现此错误.
I'm getting this error when trying to run my project.
试图清除ivy2缓存没有成功.这就是我的构建sbt的样子:
tried to clear ivy2 cache with no success .this is how my build sbt looks like :
scalaVersion := "2.11.7"
scalacOptions := Seq("-unchecked", "-feature", "-deprecation", "-encoding", "utf8")
resolvers ++= Seq(
Resolver.sonatypeRepo("releases"),
Resolver.sonatypeRepo("snapshots"),
Resolver.bintrayRepo("websudos", "oss-releases"),
"spray repo" at "http://repo.spray.io",
"Typesafe repository snapshots" at "http://repo.typesafe.com/typesafe/snapshots/",
"Typesafe repository releases" at "http://repo.typesafe.com/typesafe/releases/",
"Sonatype repo" at "https://oss.sonatype.org/content/groups/scala-tools/",
"Sonatype releases" at "https://oss.sonatype.org/content/repositories/releases",
"Sonatype snapshots" at "https://oss.sonatype.org/content/repositories/snapshots",
"Sonatype staging" at "http://oss.sonatype.org/content/repositories/staging",
"Sonatype" at "https://oss.sonatype.org/content/groups/public/",
"Java.net Maven2 Repository" at "http://download.java.net/maven/2/",
"Twitter Repository" at "http://maven.twttr.com"
)
libraryDependencies ++= {
val phantomV = "1.29.5"
val scalaTestV = "3.0.0"
val elastic4sV = "2.4.0"
val akkaStreamVersion = "2.4.2"
val akkaVersion = "2.3.11"
Seq(
"com.websudos" %% "phantom-dsl" % phantomV,
"com.websudos" %% "phantom-reactivestreams" % phantomV,
"com.websudos" %% "util-testing" % "0.13.0" % "test, provided",
"com.typesafe.akka" %% "akka-actor" % akkaVersion,
"com.typesafe.akka" %% "akka-http-spray-json-experimental" % akkaStreamVersion,
"com.typesafe.akka" %% "akka-http-core" % akkaStreamVersion,
"com.typesafe.akka" %% "akka-http-experimental" % akkaStreamVersion,
"com.typesafe.akka" %% "akka-http-testkit" % akkaStreamVersion,
"org.scalatest" %% "scalatest" % scalaTestV % "test",
"com.typesafe.akka" %% "akka-testkit" % akkaVersion % "test",
"com.typesafe.play" %% "play-streams-experimental" % "2.4.6",
"com.sksamuel.elastic4s" %% "elastic4s-core" % elastic4sV,
"com.sksamuel.elastic4s" %% "elastic4s-streams" % elastic4sV
)
}
lazy val root = project.in(file(".")).configs(IntegrationTest)
Defaults.itSettings
initialCommands := """|import akka.actor._
|import akka.pattern._
|import akka.util._
|import scala.concurrent._
|import scala.concurrent.duration._""".stripMargin
fork in run := true
知道如何解决吗?
更新:java.class.path显示
UPDATE:java.class.path shows
推荐答案
这听起来像是类路径问题.您可能正在使用一个调用(使用)Typesafe Config的库,但是路径中Typesafe Config的版本小于1.3.0. Typesafe Config 1.3.0中引入了找不到的方法.要查看您的运行时类路径,请确保首先执行以下语句(即在您的应用崩溃之前):
It sounds like a classpath problem. You may be using a library that calls (uses) Typesafe Config, but the version of Typesafe Config in your path is less than 1.3.0. The method that is not found was introduced in Typesafe Config 1.3.0. To see your runtime classpath, make sure these statements are the first ones that are executed (i.e. before your app crashes):
val cp = System.getProperty("java.class.path")
val sep = System.getProperty("path.separator")
cp.split(sep).foreach(println)
一旦发现您没有Typesafe Config 1.3.0,请将其添加为显式依赖项.
Once you see that you do not have Typesafe Config 1.3.0, add it as an explicit dependency.
这篇关于如何解决类型安全配置上的NoSuchMethodError?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!