斯卡拉模块
问题描述:
我可以在这里问一些新手的问题:斯卡拉模块
我的目标是在斯卡拉(2.11.5)使用微风模块(0.10),于是我跟着:
$ sbt
set scalaVersion := "2.10.3" // or 2.11.3
set libraryDependencies += "org.scalanlp" %% "breeze" % "0.10"
set resolvers += "Sonatype Releases" at "https://oss.sonatype.org/content/repositories/releases/"
console
和实际上,它运行良好,并在年底,当我接到提示我能做好这一点(从微风网站的一些例子)
import breeze.linalg._
然而,经过我刚好
退出并重新进入斯卡拉$ scala
Welcome to Scala version 2.11.5 (Java HotSpot(TM) 64-Bit Server VM, Java 1.7.0_75).
Type in expressions to have them evaluated.
Type :help for more information.
scala>
,并与一些激动,我想:
scala> import breeze.linalg._
<console>:7: error: not found: value breeze
import breeze.linalg._
^
看来模块“水涨船高”,安装后... 我可以知道如何“微风”永久安装?还是我错过了这里的任何联系?
您的回答非常感谢。
答
scala/java生态系统不会那样工作;全局类路径不会更改,因为某些项目使用jar。
最简单的解决方法是创建一个调用相同sbt咒语的bash别名(例如brscala)。
有一些方法可以使它工作(包括将符号链接放在$ SCALA_HOME/lib中的所有依赖项),但这绝对不被推荐。
答
看起来你要访问的库从终端
-
指定的依赖关系(这里微风&鞍)在build.sbt,例如
scalaVersion := "2.10.4" resolvers ++= Seq( "Sonatype OSS Releases" at "http://oss.sonatype.org/content/repositories/releases/", "Sonatype OSS Snapshots" at "http://oss.sonatype.org/content/repositories/snapshots/", "Sonatype Snapshots" at "https://oss.sonatype.org/content/repositories/snapshots/", "Sonatype Releases" at "https://oss.sonatype.org/content/repositories/releases/" ) libraryDependencies ++= Seq( "joda-time" % "joda-time" % "2.1", "org.joda" % "joda-convert" % "1.2", "org.scala-saddle" %% "saddle-core" % "1.3.+", "org.specs2" %% "specs2" % "2.4.1" % "test", "org.scalacheck" %% "scalacheck" % "1.11.3" % "test", "junit" % "junit" % "4.11" % "test", "org.scalanlp" %% "breeze" % "0.12", "org.scalanlp" %% "breeze-natives" % "0.12", "org.scalanlp" %% "breeze-viz" % "0.12" ) initialCommands := """ import org.joda.time.DateTime import org.saddle._ import org.saddle.time._ import org.saddle.io._ import me.first_install_saddle._ import breeze.linalg._"""
假设你是cd到build.sbt的目录:运行
sbt update
安装依赖- 然后,而不是仅仅
scala
,在 终端运行
sbt console
从那里你可以从终端访问这些库。