问题描述
我需要为Maven设置HTTP代理来访问存储库。 但是,由于给定的环境,我无法在Maven settings.xml文件中设置代理。
所以我想知道是否可以在项目pom.xml文件(或项目或mvn命令中的其他任何位置)中设置代理。
这可能吗?如果可以,怎么办?谢谢!
解决方法
好的,我明白了
一个人可以使用 custom settings.xml :mvn -s settings.xml ...
来调用Maven,并使用这样的自定义settings.xml(例如pom.xml旁)。代理的以下内容:
<?xml version="1.0" encoding="UTF-8"?>
<settings xmlns="http://maven.apache.org/SETTINGS/1.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.0.0 http://maven.apache.org/xsd/settings-1.0.0.xsd">
<proxies>
<proxy>
<id>proxy_http</id>
<active>true</active>
<protocol>http</protocol>
<host>proxy.example.com</host>
<port>8080</port>
<nonProxyHosts>example.com</nonProxyHosts>
</proxy>
<proxy>
<id>proxy_https</id>
<active>true</active>
<protocol>https</protocol>
<host>proxy.example.com</host>
<port>8080</port>
<nonProxyHosts>example.com</nonProxyHosts>
</proxy>
</proxies>
</settings>