我试图从代理后面访问maven存储库 . 我正确配置了settings.xml(我猜是这样......)
<proxies>
<proxy>
<active>true</active>
<protocol>http</protocol>
<username>username</username>
<password>password</password>
<host>12.34.56.78</host>
<port>8080</port>
</proxy>
</proxies>
但我仍然得到一个错误消息,如...如果我没有配置用户ID /密码获取正确的错误消息,这是HTTP响应代码 407
- 说需要身份验证 . 但是,如果我配置正确/不正确的代理身份验证,它始终打印下面的错
Downloading: http://repo1.maven.org/maven2/org/apache/maven/plugins/maven-clean-plugin/2.2/maven-clean-plugin-2.2.pom
[WARNING] Unable to get resource 'org.apache.maven.plugins:maven-clean-plugin:pom:2.2' from repository central (http://repo1.maven.org/maven2): Error trans
ferring file: Server redirected too many times (20)
Downloading: http://repo1.maven.org/maven2/org/apache/maven/plugins/maven-clean-plugin/2.2/maven-clean-plugin-2.2.pom
[WARNING] Unable to get resource 'org.apache.maven.plugins:maven-clean-plugin:pom:2.2' from repository central (http://repo1.maven.org/maven2): Error trans
ferring file: Server redirected too many times (20)
[INFO] ------------------------------------------------------------------------
[ERROR] BUILD ERROR
4 回答
它是NTLM代理吗?如果是,请尝试为
username
提供domainname\username
(如this thread中所示) .如果以上不起作用
Step #2: Add wagon-http-lightweight extension
Wagon HTTP轻量级库允许我们在使用NTLM代理时克服Maven(3.0.4)中的身份验证限制 . 我们可以按照以下步骤将Wagon HTTP轻量级库添加为Maven扩展:
从here下载
wagon-http-lightweight-2.2.jar
.将
wagon-http-lightweight-2.2.jar
复制到%M2_HOME%/lib/ext
文件夹 .Example pom.xml to test the solution
要测试我们的方法,首先使用以下pom.xml创建一个简单的Maven项目:
运行Maven目标如下所述 . 这应该成功执行并下载所有Maven依赖项:
检查本地存储库目录(在settings.xml文件中定义)以确保正确下载所有依赖项 .
另一种方法是在您的计算机上获取Cntlm(http://cntlm.sourceforge.net/),使用您的域/密码/代理名称在cntlm.ini中配置您的NTLM代理 . 运行它:
编辑您的maven $MAVEN_HOME\conf\settings.xml ,并使用代理块:
现在使用
-s
选项运行maven:我也偶然发现了这个问题,花了很多时间来寻找解决NTLM错误的方法 . 即使我们在代理标记中使用域名前缀用户名,NTLM问题也不会消失,我们还需要在服务器标签中为用户ID添加前缀,如下所示......