SBT在本地Maven仓库中找不到文件,尽pipe它在那里

我在我的本地仓库中的Maven依赖关系有问题。

SBT找不到它。 已经设置日志级别进行debugging,但没有得到任何新东西。

这些文件在存储库中。 我从控制台复制粘贴path到文件资源pipe理器,他们在那里。

输出:

[debug] trying file://c:/Users/userz/.m2/repository/com/twitter/naggati/2.0.0/naggati-2.0.0.pom [debug] tried file://c:/Users/userz/.m2/repository/com/twitter/naggati/2.0.0/naggati-2.0.0.pom [debug] Local Maven Repository: resource not reachable for com/twitter#naggati;2.0.0: res=file://c:/Users/userz/.m2/repository/com/twitter/naggati/2.0 .0/naggati-2.0.0.pom [debug] trying file://c:/Users/userz/.m2/repository/com/twitter/naggati/2.0.0/naggati-2.0.0.jar [debug] tried file://c:/Users/userz/.m2/repository/com/twitter/naggati/2.0.0/naggati-2.0.0.jar [debug] Local Maven Repository: resource not reachable for com/twitter#naggati;2.0.0: res=file://c:/Users/userz/.m2/repository/com/twitter/naggati/2.0 .0/naggati-2.0.0.jar [debug] Local Maven Repository: no ivy file nor artifact found for com.twitter#naggati;2.0.0 

编辑:我添加了项目/构build中使用scala文件的path,如http://code.google.com/p/simple-build-tool/wiki/LibraryManagement

“sbt可以search你的本地Maven仓库,如果你把它添加为一个仓库:”

 val mavenLocal = "Local Maven Repository" at "file://"+Path.userHome+"/.m2/repository" 

这使得在本地存储库中查找。 之前没有。

所以scala文件看起来像这样:

 import sbt._ class Foo(info: ProjectInfo) extends DefaultProject(info) { val mavenLocal = "Local Maven Repository" at "file://c:/Users/userz/.m2/repository" } 

(我硬编码Path.userHome排除可能的错误原因。正如所料,它没有改变任何东西)。

file:说明符后面需要三个斜杠。 这是因为在第二个和第三个斜杠之间,你有一个可选的主机名。 维基百科对file: URL的解释很好

你遇到了一个问题,因为典型的"file://"+Path.userHome+"/.m2/repository"假设一个Unix文件系统,其中path以/开始,包含no "file://"+Path.userHome+"/.m2/repository"并且通常不包含空格。

要在Windows和Linux / Unix上都有非硬编码的path,请使用:

 "Local Maven" at Path.userHome.asFile.toURI.toURL + ".m2/repository" 

只需在build.scala或build.sbt文件中添加此行即可

 resolvers += Resolver.mavenLocal 

为了使它适用于更新版本的sbt,请将以下内容添加到build.sbt中:

 resolvers += "Local Maven Repository" at "file:///"+Path.userHome+"/.m2/repository" 

当你有一个项目定义时,注意你需要在设置中包含parsing器。 全球parsing器将不会被识别。

例:

 lazy val core = (project in file("core")). settings(commonSettings: _*). settings( resolvers += Resolver.mavenLocal, name := "Core", libraryDependencies := coreDependencies )