wget 无法从 Maven 存储库下载 jar 文件
我正在尝试从下面的 URL 从 Maven 存储库下载单个 jar 文件。
http://repo1.maven .org/maven2/com/google/guava/guava-testlib/10.0/guava-testlib-10.0.jar
在浏览器中下载有效很好,我按预期得到了文件。
“wget”下载了一些东西,但我得到的文件似乎无效。在下载的文件上运行“jar -tf”会出现“ZipException:打开 zip 文件时出错”。
以编程方式从 Java 下载文件(从 URL 写入“FileOutputStream”的“InputStream”)会下载内容并创建文件。使用 WinZip/7-Zip 打开该文件,它似乎包含一个名为“guava-testlib-10.0”的文件,该文件看起来像我期望获得的 jar 存档。
wget
另一个 jar 至少有时会按预期工作(使用-U
用户代理字符串)
这是 wget/maven 或 Java/maven 之间的一些狡猾的交互吗?我的浏览器是否可以正确理解并正确下载该 jar 文件?这两点对我来说似乎都有点难以置信。
I'm trying to download a single jar file from the maven repository, from the URL below.
http://repo1.maven.org/maven2/com/google/guava/guava-testlib/10.0/guava-testlib-10.0.jar
Downloading in a browser works fine, and I get the file as expected.
'wget' downloads something, but the file I get doesn't appear to be valid. Running 'jar -tf' on the downloaded file gives 'ZipException: error in opening zip file'.
Downloading the file programmatically from Java ('InputStream' from the URL writing to a 'FileOutputStream') downloads something and creates the file. Opening that with WinZip/7-Zip, it appears to contain one file named 'guava-testlib-10.0', which looks like the jar archive I was expecting to get.
wget
another jar does work as expected at least sometimes (with-U
user agent string)
Is this some dodgy interaction between wget/maven or Java/maven? Is it a malformed jar file that my browser understands and downloads correctly? Both of those seem slightly implausible to me.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
wget 通常会被中央 Maven 存储库阻止,因为有些人玩得不好并且尝试使用 wget 太多。尝试设置用户代理:
wget generally gets blocked from the central maven repo because some people don't play nice and try to wget too much. Try set the user agent: