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 | Specification for one proxy, to be used in connecting to the network. | <proxy> <id>optional</id> <active>true</active> <protocol>https</protocol> <username>JackLi</</username> <password>abc123</password> <host>webproxy.company.com</host> <port>8081</port> <!-- <nonProxyHosts>local.net|some.host.com</nonProxyHosts> --> </proxy> --> </proxies>
按照上述步骤操作后,我们应该也可以在代理服务器后面使用 maven。
查看更多教程 https://on itroad.com
Eclipse中Maven代理设置
要在使用 Maven 时在 Eclipse 中使用代理设置,请按照下列步骤操作:
- 打开 Eclipse 并转到窗口 -> 首选项。
- 单击“用户设置”的“浏览”按钮,然后选择 settings.xml 。
Eclipse 中的 Maven 代理
- 点击
“更新设置”
按钮来更新设置。如果出现任何确认对话框,只需单击是。
要设置 maven 代理设置,请按照以下步骤操作:
- 导航到路径 - {M2_HOME}/conf/settings.xml
- 在任何文本编辑器中以编辑模式打开文件 settings.xml。
- 打开并更新 <proxy> 标签。
这个标签看起来像这样:
<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 | 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 | Specification for one proxy, to be used in connecting to the network. | <proxy> <id>optional</id> <active>true</active> <protocol>http</protocol> <username>proxyuser</</username> <password>proxypass</password> <host>proxy.host.net</host> <port>80</port> <nonProxyHosts>local.net|some.host.com</nonProxyHosts> </proxy> --> </proxies> </settings>
使用网络特定凭据更新上述代理服务器字段。
我们可以在浏览器的连接设置中找到网络代理详细信息。
例如,可以在以下位置找到代理设置
Internet Explorer >> tools >> internet options >> Connections >> LAN Settings Firefox >> tools >> options >> ADVANCED TAB >> settings
从命令行设置 Maven 代理
为了节省时间,我们可以在 maven 命令的末尾添加代理详细信息。
$ mvn clean install -DproxySet=true -DproxyHost=ur.proxy.server -DproxyPort=port
日期:2020-09-17 00:10:54 来源:oir作者:oir