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

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

问题描述

我在代理服务器后面使用 Maven 3.1.1.同一个代理处理 HTTPHTTPS 流量.

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>

是否可以在 maven 的 settings.xml 中为 HTTPHTTPS 配置代理?我知道我可以通过将 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

但是这肯定可以在 settings.xml 中实现吗?

but surely this must be possible from within settings.xml?

Maven 错误,例如 MNG-2305MNG-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,因此您只需要定义一个代理服务器,它就会用于两者,您只需只需要留下一个 proxy 标签,像这样:

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天全站免登陆