Maven错误:URI具有权限组件

时间:2016-10-04 14:53:43

标签: maven uri

我对maven很新,并试图在Windows上构建一个在linux上运行良好的代码。 我的pom.xml中有2个本地存储库:

<repositories>
    <repository>
        <id>p2-repo-equinox_3.8.1</id>
        <layout>p2</layout>
        <url>file:///${basedir}/../xyz/abc/repository/</url>
    </repository>
    <repository>
        <id>p2-repo-common</id>
        <layout>p2</layout>
        <url>file:///${basedir}/../xyz/def/repository/</url>
    </repository>
</repositories>

构建时,我收到错误:

 Internal error: java.lang.RuntimeException: Failed to load p2 repository with ID 'p2-repo-equinox_3.8.1' from location file://D:/maven/myproject/../xyz/abc/repository/: URI has an authority component -> [Help 1]

我找到this post,并尝试添加第三个斜杠来传递一个空的权限组件(file:///),这使得它可以工作,但我不确定为什么这个问题只发生在Windows中首先而不是Linux。

任何建议都表示赞赏。

2 个答案:

答案 0 :(得分:1)

这不会在Linux上引起错误的原因可能是由于两个平台上的 $ {basedir} 值不同:

在Windows上, $ {basedir} 将被设置为“ c:/ file / path”

photoObjects

在linux $ {basedir} 上,会像“ / file / path”

file://c:/file/path   <--- not happy

答案 1 :(得分:0)

在Windows机器上,完整语法为 file:// host / path 如果主机是您的计算机(localhost),则可以省略它,从而生成 file:/// path

请参阅RFC 1738 – Uniform Resource Locators (URL)

A file URL takes the form:

file://<host>/<path>
[…]

As a special case, <host> can be the string "localhost" or the empty string; this is interpreted as 'the machine from which the URL is being interpreted'.