如何在Maven的settings.xml中为HTTP和HTTPS配置代理服务器? [英] How to configure a proxy server for both HTTP and HTTPS in Maven's settings.xml?

查看:418
本文介绍了如何在Maven的settings.xml中为HTTP和HTTPS配置代理服务器?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在代理服务器后面使用Maven 3.1.1。同一个代理处理 HTTP HTTPS 流量。

I'm using Maven 3.1.1 behind a proxy server. The same proxy handles both HTTP and HTTPS traffic.

我似乎无法告诉maven使用 settings.xml 来使用这两种协议。在我看来,只能使用一个活动代理,因为首先使用了定义的活动代理,并忽略后续的活动代理定义。这是我的 settings.xml

I can't seem to tell maven using settings.xml to use both protocols. It seems to me that it is only possible to have one active proxy, as whichever active proxy is defined first is used, and subsequent 'active' proxy definitions are ignored. This is my 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>

是否可以为 HTTP HTTPS 在maven的 settings.xml 中?我知道我可以通过将Java系统属性传递给maven调用来解决这个问题,例如:

Is it possible to configure a proxy for both HTTP and HTTPS in maven's settings.xml? I'm aware that I could workaround this by passing Java system properties to the maven invocation such as:

-Dhttps.proxyHost=192.168.1.2 -Dhttps.proxyPort=3128

但肯定必须在<$ c $内c> settings.xml

提出的Maven错误,例如 MNG-2305 MNG -4394 建议此问题已解决,但我不相信。

Maven bugs raised such as MNG-2305 and MNG-4394 suggest this issue is resolved, but I am not convinced.

或者,是否有代理代理我可以在本地运行,我可以指出maven到? 代理代理将相应地路由http / https。即便如此,我仍然需要在 settings.xml 中为Maven定义两个活动代理定义来指导这两种类型的流量。

Alternatively, is there a "proxy proxy" I could run locally that I could point maven to? The "proxy proxy" would route http/https accordingly. Even so, I would still need to define two active proxy definitions in settings.xml for Maven to direct both types of traffic.

推荐答案

来自settings.xml的Maven代理用于http和https,因此您只需要定义一个代理服务器并将其用于两者,您只需要离开只有一个代理商标签,如下所示:

Maven proxy from settings.xml is used for both http and https, so you just need to define one proxy server and it will be used for both, you just need to leave only one proxy tag, like this:

<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>

上述协议是代理服务器的协议,而不是代理请求。

The protocol above is the protocol of the proxy server, not the proxied request.

这篇关于如何在Maven的settings.xml中为HTTP和HTTPS配置代理服务器?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆