开发者

wget not working to download jar file from maven repo

开发者 https://www.devze.com 2023-04-09 22:46 出处:网络
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

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开发者_如何学C 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.


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:

wget -U "Any User Agent" http://repo1.maven.org/maven2/com/google/guava/guava-testlib/10.0/guava-testlib-10.0.jar
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号