【问题标题】:How to install library with SBT libraryDependencies in an Intellij project如何在 Intellij 项目中使用 SBT libraryDependencies 安装库
【发布时间】:2015-08-03 08:30:37
【问题描述】:

我对 SBT、Breeze 和 IntelliJ 非常陌生,尽管我对 Scala 有相当的了解,并且我正在尝试安装 Breeze 库,我认为它是托管的。

我做了什么:

我按照this page 上的说明,将此脚本添加到我项目中的build.sbt 文件中:

libraryDependencies  ++= Seq(
            // other dependencies here
            "org.scalanlp" %% "breeze" % "0.10",
            // native libraries are not included by default. add this if you want them (as of 0.7)
            // native libraries greatly improve performance, but increase jar sizes.
            "org.scalanlp" %% "breeze-natives" % "0.10"
)

resolvers ++= Seq(
            // other resolvers here
            "Sonatype Releases" at "https://oss.sonatype.org/content/repositories/releases/"
)

// Scala 2.9.2 is still supported for 0.2.1, but is dropped afterwards.
scalaVersion := "2.11.1" // or 2.10.3 or later

然后我在项目目录中运行sbt update(通过终端),看到所有的微风都下载了。

然后我尝试重新运行sbt update,但这并没有触发另一个下载。

问题:

问题是我无法通过 IntelliJ 访问该库。 import breeze._ 给出了标准 Cannot resolve symbol breeze,我在“项目结构”中找不到任何提及 Breeze。它也不在项目的lib目录中。

我错过了一步吗?

【问题讨论】:

  • 第一次打开项目时 IntelliJ 中的“自动导入”票?如果不是,可能值得从 IntelliJ 的主菜单重新导入它
  • 这很奇怪。我似乎无法将其切换为打开...它实际上没有响应。我尝试重新启动它,但仍然没有。
  • 从项目目录中删除.idea文件夹,从头开始尝试。
  • 对,我找到了另一种方式 Settings>Buid,Execution,Deployment>SBT>Use auto-import,但这并没有修复它。
  • 如果你在终端中运行“sbt compile”是否成功?是否只是 IntelliJ 导致了问题?

标签: scala intellij-idea sbt scala-breeze


【解决方案1】:

听起来像是 IntelliJ 项目中的错误,请尝试从项目目录中删除 .idea 目录,然后使用向导将项目重新导入 IntelliJ。

【讨论】:

  • ...并在导入向导中选择“从现有项目模型导入-> SBT”...
猜你喜欢
  • 2016-10-31
  • 1970-01-01
  • 2020-01-03
  • 2011-05-14
  • 1970-01-01
  • 1970-01-01
  • 2019-06-20
  • 2017-01-27
  • 2014-06-14
相关资源
最近更新 更多