2015-12-23 76 views
2

我需要在最簡單的scala項目中安裝一些依賴項(我正在通過一些教程),其中一個來自github。我build.sbt看起來是這樣的:無法從github導入已安裝的scala/sbt庫依賴項

import sbt._ 

lazy val root = Project("root", file(".")) 
    .dependsOn(smile) 
    .settings(
     name := "Xyclade ML practical examples", 
     version := "1.0", 
     scalaVersion := "2.10.6", 
     sbtVersion := "0.13.9", 
     libraryDependencies += "org.scala-lang" % "scala-swing" % "2.10.2" 
    ) 

lazy val smile = ProjectRef(uri("https://github.com/haifengl/smile.git#master"), "root") 

也許,我缺少一些基本的斯卡拉/ SBT知識(我是一個完整的小白),但:

1)import com.github.haifengl._失敗object github is not a member of package com

2) import smile._導致錯誤not found: object smile

而據我發現,庫包應該被稱爲像com.github.haifenglhttps://github.com/haifengl/smile/search?utf8=%E2%9C%93&q=com.github.haifengl&type=Code

回答

2

你確定包com.github.haifengl在你提到的github項目中嗎?它可能在它的一些依賴關係中嗎?

不要添加ProjectRef到github上的項目,而不是你最好把它添加到依賴關係:

"com.github.haifengl" % "smile-core" % "1.0.4" 

像以下:

import sbt._ 

lazy val root = Project("root", file(".")) 
    .settings(
     name := "Xyclade ML practical examples", 
     version := "1.0", 
     scalaVersion := "2.10.6", 
     sbtVersion := "0.13.9", 
     libraryDependencies += Seq(
       "org.scala-lang" % "scala-swing" % "2.10.2", 
       "com.github.haifengl" % "smile-core" % "1.0.4" 
    ) 
+0

@先生-V,這是工作,謝謝!我可以通過調用'import smile._'來導入lib。但是我不能使用它的任何類,例如'val plot = ScatterPlot ...'失敗,'找不到:值ScatterPlot'。或者我應該在斯卡拉的某個地方明確聲明這個類? –

+0

通過'import smile.plot._'修復了這個問題(對於這種愚蠢的錯誤來說)。再次感謝! –