用ANT设置代理

时间:2015-06-13 14:19:47

标签: java ant proxy

Java版本:1.8.0 蚂蚁版:1.7.1

我正在尝试执行此ant来构建jar文件。这个蚂蚁还与maven进行http连接以下载一些jar文件:

由于我支持代理,我首先这样做:

export ANT_OPTS="-Dhttp.proxyHost=prod.proxy.net -Dhttp.proxyPort=8080 -Dhttp.proxyUsername=smithJ -Dhttp.proxyPassword=Basketball123"

然后我执行:

CLASSPATH=/app/hbase-0.94.27/lib/hadoop-core-1.0.4.jar CFLAGS=-m64 CXXFLAGS=-m64 ant -v compile-native tar

我收到这些错误:

ivy-download:
      [get] Getting: http://repo2.maven.org/maven2/org/apache/ivy/ivy/2.2.0/ivy-2.2.0.jar
      [get] To: /app/hadoop-lzo/ivy/ivy-2.2.0.jar
      [get] Error opening connection java.io.IOException: Server returned HTTP response code: 407 for URL: http://repo2.maven.org/maven2/org/apache/ivy/ivy/2.2.0/ivy-2.2.0.jar
      [get] Error opening connection java.io.IOException: Server returned HTTP response code: 407 for URL: http://repo2.maven.org/maven2/org/apache/ivy/ivy/2.2.0/ivy-2.2.0.jar
      [get] Error opening connection java.io.IOException: Server returned HTTP response code: 407 for URL: http://repo2.maven.org/maven2/org/apache/ivy/ivy/2.2.0/ivy-2.2.0.jar
      [get] Can't get http://repo2.maven.org/maven2/org/apache/ivy/ivy/2.2.0/ivy-2.2.0.jar to /app/hadoop-lzo/ivy/ivy-2.2.0.jar

407错误是代理身份验证错误。我在这做错了什么?我如何在代理中进行身份验证以获取http文件?

我也试过这个:

 CLASSPATH=/app/hbase-0.94.27/lib/hadoop-core-1.0.4.jar CFLAGS=-m64 CXXFLAGS=-m64 ant -Dhttp.proxyHost=prod.proxy.net -Dhttp.proxyPort=8080 -Dhttp.proxyUsername=smithJ -Dhttp.proxyPassword=Basketball123  compile-native tar

仍然有407个错误。

1 个答案:

答案 0 :(得分:2)

检查一下:

set ANT_OPTS=-Dhttp.proxyHost=myproxyhost -Dhttp.proxyPort=8080 -Dhttp.proxyUser=myproxyusername -Dhttp.proxyPassword=myproxypassword -Dhttps.proxyHost=myproxyhost -Dhttps.proxyPort=8080

指南为"-Dhttp.proxyUser",而不是"-Dhttp.proxyUsername=smithJ",这就是为什么我总是告诉别人复制而不是打字。

指南:http://ant.apache.org/ivy/faq.html