Intellij的SBT和外部图书馆

时间:2014-01-18 19:24:34

标签: scala intellij-idea

我正在开始一个Scala项目,我正在使用SBT和Intellij 13作为我的IDE。

我有以下build.sbt文件,但是在运行“sbt update”后,我似乎无法在SBT“libraryDependencies”部分中获取依赖项以显示在“外部库”中。

以下是我的build.sbt:

name := "myapp-scala"

version := "1.0"

scalaVersion := "2.10.3"

resolvers += "spray repo" at "http://repo.spray.io"

resolvers += "spray nightlies" at "http://nightlies.spray.io"

libraryDependencies ++= Seq(
  "com.typesafe.akka"  %% "akka-actor"       % "2.2.0",
  "com.typesafe.akka"  %% "akka-slf4j"       % "2.2.0",
  "ch.qos.logback"      % "logback-classic"  % "1.0.13",
  "io.spray"            % "spray-can"        % "1.2-20130712",
  "io.spray"            % "spray-routing"    % "1.2-20130712",
  "io.spray"           %% "spray-json"       % "1.2.3",
  "org.specs2"         %% "specs2"           % "1.14"         % "test",
  "io.spray"            % "spray-testkit"    % "1.2-20130712" % "test",
  "com.typesafe.akka"  %% "akka-testkit"     % "2.2.0"        % "test",
  "com.novocode"        % "junit-interface"  % "0.7"          % "test->default",
  "org.scalautils" % "scalautils_2.10" % "2.0",
  "org.scalatest" % "scalatest_2.10" % "2.0" % "test"
)

scalacOptions ++= Seq(
  "-unchecked",
  "-deprecation",
  "-Xlint",
  "-Ywarn-dead-code",
  "-language:_",
  "-target:jvm-1.7",
  "-encoding", "UTF-8"
)

有人能指出我正确的方向吗?

enter image description here

4 个答案:

答案 0 :(得分:10)

开始使用IDEA 13和sbt项目的最佳方法是:

  • 确保您已安装sbt插件

enter image description here enter image description here enter image description here

  • 如果安装了它,那么只需启动一个sbt项目:

enter image description here enter image description here

这应该可以解决所有问题,您可以通过sbt控制台运行命令:

enter image description here

答案 1 :(得分:1)

要将Sbt与Intellij IDEA集成,您需要使用此插件: https://github.com/mpeltonen/sbt-idea

它为您提供了Sbt任务gen-idea,它将生成为您的项目配置IDEA所需的文件。

答案 2 :(得分:0)

我在IntelliJ CE 14.0.2上遇到了同样的问题 build.sbt和project / build.scala文件下的项目/应用程序名称必须相同。这有助于我解决这个问题。

答案 3 :(得分:0)

与@samspired所说的相似 我刚刚将 sbt.Project 变量名称与项目模块名称的名称完全相同,它解决了问题。
转到文件 - >项目结构 - >模块
并查看模块名称是什么 - (它不必像项目目录名称,但如果你没有更改它,可能就是它)

// this file is in the path of "../Somewhere_in_file_system/MyProjectName/build.sbt"
lazy val MyProjectName /*this is the module name*/ = (project in file("."))
      .settings(
        scalaVersion := "2.11.8",
        name := "com-company-blabla-myproject" //..... and all the other sbt properties
    )
相关问题