我在代理服务器后面使用 Maven 3.1.1。同一个代理处理 HTTP
和 HTTPS
流量。
我似乎无法告诉 maven 使用 settings.xml
来使用这两种协议(protocol)。在我看来,只能有一个 Activity 代理,因为首先定义的 Activity 代理都会被使用,而随后的“Activity ”代理定义将被忽略。这是我的 settings.xml
:
<proxies>
<proxy>
<id>myhttpproxy</id>
<active>true</active>
<protocol>http</protocol>
<host>192.168.1.2</host>
<port>3128</port>
<nonProxyHosts>localhost</nonProxyHosts>
</proxy>
<proxy>
<id>myhttpsproxy</id>
<active>true</active>
<protocol>https</protocol>
<host>192.168.1.2</host>
<port>3128</port>
<nonProxyHosts>localhost</nonProxyHosts>
</proxy>
</proxies>
是否可以在maven的settings.xml
中同时为HTTP
和HTTPS
配置代理?我知道我可以通过将 Java 系统属性传递给 maven 调用来解决此问题,例如:
-Dhttps.proxyHost=192.168.1.2 -Dhttps.proxyPort=3128
但这肯定可以从 settings.xml
中实现吗?
提出的 Maven 错误,例如 MNG-2305和 MNG-4394建议解决这个问题,但我不相信。
或者,是否有一个“代理代理”我可以在本地运行,我可以指向 maven? “代理代理”将相应地路由 http/https。即便如此,我仍然需要在 settings.xml
中定义两个 Activity 代理定义,以便 Maven 引导这两种类型的流量。
最佳答案
settings.xml 中的 Maven 代理同时用于 http 和 https,所以你只需要定义一个代理服务器,它将同时用于两者,你只需要留下一个 proxy
标签,像这样:
<proxies>
<proxy>
<id>myhttpproxy</id>
<active>true</active>
<protocol>http</protocol>
<host>192.168.1.2</host>
<port>3128</port>
<nonProxyHosts>localhost</nonProxyHosts>
</proxy>
</proxies>
上面的协议(protocol)是代理服务器的协议(protocol),不是被代理的请求。
关于java - 如何在 Maven 的 settings.xml 中为 HTTP 和 HTTPS 配置代理服务器?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31032174/