Maven error: URI has an authority component
Maven error: URI has an authority component
我是 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.
任何建议表示赞赏。
在 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'.
这不会导致 linux 上出现错误的原因可能是由于两个平台上 ${basedir} 的值不同:
On Windows ${basedir} 将设置为 "c:/file/path"
file://c:/file/path <--- not happy
在 linux ${basedir} 会像 "/file/path"
file:///file/path <--- happy
我是 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.
任何建议表示赞赏。
在 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'.
这不会导致 linux 上出现错误的原因可能是由于两个平台上 ${basedir} 的值不同:
On Windows ${basedir} 将设置为 "c:/file/path"
file://c:/file/path <--- not happy
在 linux ${basedir} 会像 "/file/path"
file:///file/path <--- happy