SBT在本地maven存储库中找不到文件,尽管它存在

Ixx*_*Ixx 71 scala maven sbt

我遇到了maven依赖的问题,这个问题在我的本地资源库中.

SBT找不到它.已经将日志级别设置为调试,但没有获得任何新内容.

这些文件位于存储库中.我将粘贴路径从控制台复制到文件资源管理器,它们就在那里.

输出:

[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
Run Code Online (Sandbox Code Playgroud)

编辑:我在项目/构建中使用scala文件添加了路径,http://code.google.com/p/simple-build-tool/wiki/LibraryManagement中所述

"如果你将它添加为存储库,sbt可以搜索你当地的Maven存储库:"

val mavenLocal = "Local Maven Repository" at "file://"+Path.userHome+"/.m2/repository"
Run Code Online (Sandbox Code Playgroud)

这使得sbt看起来在本地存储库中.之前没有.

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

import sbt._

class Foo(info: ProjectInfo) extends DefaultProject(info) {

val mavenLocal = "Local Maven Repository" at "file://c:/Users/userz/.m2/repository"

}
Run Code Online (Sandbox Code Playgroud)

(我硬编码Path.userHome以排除可能的错误原因.正如预期的那样,它没有改变任何东西).

Ben*_*ied 135

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

resolvers += Resolver.mavenLocal
Run Code Online (Sandbox Code Playgroud)

  • `Global中的解析器:= Resolver.mavenLocal`适合我. (5认同)
  • 那是什么意思?我用它0.13.11,它工作得很好. (2认同)
  • 对于 SBT 1.3.x,它是`ThisBuild/resolvers += Resolver.mavenLocal` (2认同)

lee*_*777 60

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

您遇到了问题,因为"file://"+Path.userHome+"/.m2/repository"假定Unix文件系统的典型模式,其中路径以a开头/,包含no :,并且通常不包含空格.

要拥有适用于Windows和Linux/Unix的非硬编码路径,请使用:

"Local Maven" at Path.userHome.asFile.toURI.toURL + ".m2/repository"
Run Code Online (Sandbox Code Playgroud)


Mar*_*ius 21

要使这适用于较新版本的sbt,请将以下内容添加到build.sbt:

resolvers += "Local Maven Repository" at "file:///"+Path.userHome+"/.m2/repository"
Run Code Online (Sandbox Code Playgroud)