maven - 在 pom.xml 中为 Maven 设置代理(不在 settings.xml 中)
问题描述
我需要为 Maven 设置一个 HTTP 代理来访问存储库。但是,由于给定的环境,我无法在 Maven settings.xml 文件中设置代理。
所以我想知道是否可以在项目 pom.xml 文件(或项目或 mvn 命令中的任何其他位置)中设置代理。
这可能吗?如果可以,怎么做?谢谢!
解决方案
好,我知道了:
可以使用自定义 settings.xml调用 Maven :mvn -s settings.xml ...
并拥有这样一个自定义 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>
推荐阅读
- r - 在 R 中安装测试套件中使用的所有软件包?
- sql - Postgresql 多对多表的最佳搜索方式 - 排除和包含标签
- django - 在django的表单的action中设置输入字段的值
- eclipse - 从 Eclipse Selenium Java 中的控制台获取 HTML 中的所有表单标签
- javascript - html数字只有最小值和最大值
- javascript - 带有 jquery 日期时间选择器的 ASP Web 应用程序问题
- powershell - 如何在函数中创建条件参数?
- c# - Xamarin 崩溃:System.MissingMethodException:找不到方法:void .ResourceLoadingQuery.set_Instance(object)
- elasticsearch - 在 ElasticSearch 中查询列表的第一个元素
- vue.js - 如何在没有 webpack 的情况下在 Vue.js 中加载环境变量?