SBT在本地Maven存储库中找不到文件 [英] SBT doesn't find file in local maven repository although it's there

查看:232
本文介绍了SBT在本地Maven存储库中找不到文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的本​​地存储库中的Maven依赖项出现问题.

I'm having problems with a maven dependency which is in my local respository.

SBT找不到它.已将日志级别设置为要调试,但未获取任何新内容.

SBT can't find it. Already set log level to debug, but not getting anything new.

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

The files are in the repository. I copy paste paths from the console to file explorer and they are there.

输出:

[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

我在项目/版本中使用scala文件添加了路径,如http://code.google.com/p/simple-build-tool/wiki/LibraryManagement

I added the path using scala file in project/build like described in http://code.google.com/p/simple-build-tool/wiki/LibraryManagement

" sbt可以搜索本地Maven存储库,如果您将其添加为存储库:"

"sbt can search your local Maven repository if you add it as a repository:"

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

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

That made sbt look in the local repository. Before it didn't.

因此scala文件如下所示:

So the scala file looks like this:

import sbt._

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

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

}

(我对Path.userHome进行了硬编码,以排除可能的错误原因.正如预期的那样,它什么都没有改变.)

(I hardcoded Path.userHome to exclude possible error reason. As expected it didn't change anything).

推荐答案

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

You need three slashes after the file: specifier. This is because between the second and third slash, you have an optional hostname. Wikipedia has a good explanation of file: URL's

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

You're having a problem because the typical pattern of "file://"+Path.userHome+"/.m2/repository" assumes a Unix filesystem, where the path begins with a /, contains no :, and usually contains no spaces.

要拥有在Windows和Linux/Unix上都可以使用的非硬编码路径,请使用:

To have a non-hardcoded path that works on both Windows and Linux/Unix, use:

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

这篇关于SBT在本地Maven存储库中找不到文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆