Maven允许定义多个代理:
<!-- proxies
| This is a list of proxies which can be used on this machine to connect to the network.
| Unless otherwise specified (by system property or command-line switch), the first proxy
| specification in this list marked as active will be used.
|-->
<proxies>
<proxy>
<id>proxy_gcp</id>
<active>true</active>
<protocol>http</protocol>
<host>app-proxy.gcp.acme.fr</host>
<port>80</port>
</proxy>
<proxy>
<id>proxy_aws</id>
<active>false</active>
<protocol>http</protocol>
<host>app-proxy.aws.acme.fr</host>
<port>80</port>
</proxy>
</proxies>
按照默认设置.xml中的规定,Unless otherwise specified (by system property or command-line switch), the first proxy specification in this list marked as active will be used
。
但我找不到任何关于如何通过系统属性或命令行开关进行其他指定的指导。
如何告诉maven使用列表中的第二个代理(命令行,或使用属性(
它指的是JVM级别的系统属性,而不是Maven属性:https://docs.oracle.com/javase/8/docs/technotes/guides/net/proxies.html
$ mvn install -Dhttp.proxyHost=<host> -Dhttp.proxyPort=<port> -Dhttp.nonProxyHosts=<nonProxyHosts>
我已经在Maven官方用户列表上提出了问题,似乎根本没有办法做到这一点:
This is a bit of problematic topic. There is no switch for proxy
enable/disable. I don't know where this comes from. You may try
> <active>${FOO}</active>
and -DFOO=...
The sytem property or CLI switch only refer to -Dhttp.proxy.. and
-Dhttps.proxy...
Note that this is a problematic solution which I don't like. This will
only work with Wagon Apache HTTP Client because we enable this. I am
included to remove this support in the next major for various reasons
and all HttpURLConnection based stuff running in the same JVM.
Everything else shall use settings.xml.
Is this sufficient as an answer? I guess am currently most skilled one
in Maven space to answer this question. If still now clear, let me know.
Michael
(邮件档案在这里:https://lists.apache.org/thread.html/r04190c918139b5e29bc231a89532532fcd19f466ce6e9298435f47e4%40%3Cusers.maven.apache.org%3E)
我想知道他们为什么一开始就列出代理人名单。