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

查看:18
本文介绍了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

我在 project/build 中使用 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: 说明符后需要三个斜杠.这是因为在第二个和第三个斜杠之间,您有一个可选的主机名.Wikipediafile: 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天全站免登陆