IntelliJ + sbt - >没有外部依赖

时间:2018-05-31 21:15:35

标签: scala intellij-idea sbt

我正在尝试使用sbt为Scala项目设置IntelliJ IDEA。外部依赖项在我的build.sbt中指定,也在IDE中列出,如屏幕截图所示。但是,我仍然遇到编译器错误,说明无法解析相应的符号。有人能指出我正确的方向吗?

build.sbt的内容:

lazy val midas = (project in file("."))
  .settings(
    name := "test",
    mainClass in assembly := Some("core.Service"),
    assemblyJarName in assembly := "test.jar",
    test in assembly := {},
    libraryDependencies ++= Seq(
      "org.slf4j" % "slf4j-api" % "1.7.25",
      "com.typesafe.akka" %% "akka-actor" % "2.5.13",
      "com.typesafe.akka" %% "akka-slf4j" % "2.5.13",
      "com.typesafe.akka" %% "akka-remote" % "2.5.13",
      "org.scala-lang.modules" %% "scala-xml" % "1.1.0",
      "com.typesafe.play" %% "play-json" % "2.6.9",
      "com.typesafe.slick" %% "slick" % "3.2.3",
      "com.typesafe.scala-logging" %% "scala-logging" % "3.9.0",
      "ch.qos.logback" % "logback-classic" % "1.2.3",
      "ch.qos.logback" % "logback-core" % "1.2.3",
      "com.mchange" % "c3p0" % "0.9.5.2",
      "joda-time" % "joda-time" % "2.10",
      "org.joda" % "joda-convert" % "2.0.1",
      "net.sourceforge.jtds" % "jtds" % "1.3.1"
    )
  )

仍然无法在IDE中解析akkajoda-time的依赖关系。但是命令行中的sbt compile工作正常。

enter image description here

1 个答案:

答案 0 :(得分:0)

joda-convert不包括org.joda.time.DateTime - 您需要"joda-time" % "joda-time" % "2.9.4"左右。

一旦你添加了这个(并修复了你丢失的Akka导入,可能是"com.typesafe.akka" %% "akka-actor" % "2.4.17"),你需要刷新sbt项目。

我按Shift,Shift键调出“Search Everywhere”并输入“sbt”。在工具窗口下选择sbt,然后在sbt窗口中单击“刷新所有sbt项目”(蓝色重新加载图标)。我关闭此窗口是因为它通常没用。

希望有所帮助。